foreach (DataRow item in table.Rows)
{
Document preDoc = AcadApp.DocumentManager.MdiActiveDocument;
Document doc = AcadApp.DocumentManager.Open(item["OldFilePath"].ToString());
AcadApp.DocumentManager.MdiActiveDocument = doc;
Document currentDoc;
using (DocumentLock documentLock = Application.DocumentManager.MdiActiveDocument.LockDocument())
{
currentDoc = AcadApp.DocumentManager.MdiActiveDocument;
ReplaceText(currentDoc,rText);
}
currentDoc.Database.SaveAs(item["OldFilePath"].ToString(), true, DwgVersion.Current, doc.Database.SecurityParameters);
}