代码如下:
using (Transaction tr = currentdb.TransactionManager.StartTransaction()){//当前数据库开启事务using (Database tempdb = new Database(false, true)) //创建临时数据库(两个参数:是否创建符号表,不与当前文档关联){try{Bitmap thumb = doc.CapturePreviewImage(200, 300);tempdb.ThumbnailBitmap = thumb;}catch (System.Exception){ed.WriteMessage($"{fullfilename}无略缩图。");} tempdb.ReadDwgFile(fileName, FileShare.Read, true, null);//临时数据库不打开dwg文档读取文件.只能读取dwg类型文件,不可读取dxftempdb.DxfOut(fullfilename,10,true);}counter = counter + 1;tr.Commit();}