不打开文件操作db时,如果遇到和窗体交互,不会提示文档未锁,但同样需要锁定当前文档,代码如下
代码
//隐藏打开图形数据库db
db = CAD.CADMgr.CADEntity.Getdb(
ConfigInfo.productPath + file.Path,
System.IO.FileShare.ReadWrite, false);
if (Application.DocumentManager.Count == 0)
{
Application.DocumentManager.Add("acadiso.dwt");
}
Document doc = Application.DocumentManager.MdiActiveDocument;
DocumentLock lockDoc = doc.LockDocument();
using (lockDoc)
{
//处理db中的块等实体
}
db = CAD.CADMgr.CADEntity.Getdb(
ConfigInfo.productPath + file.Path,
System.IO.FileShare.ReadWrite, false);
if (Application.DocumentManager.Count == 0)
{
Application.DocumentManager.Add("acadiso.dwt");
}
Document doc = Application.DocumentManager.MdiActiveDocument;
DocumentLock lockDoc = doc.LockDocument();
using (lockDoc)
{
//处理db中的块等实体
}