明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1967|回复: 1

[命令] 批量打开文件会致命错误

[复制链接]
发表于 2011-4-18 15:03 | 显示全部楼层 |阅读模式
  1.    <CommandMethod("ls1", CommandFlags.Session)> Public Sub ls1()
  2.         Dim objOpenFileDialog As Autodesk.AutoCAD.Windows.OpenFileDialog = New Autodesk.AutoCAD.Windows.OpenFileDialog("选择文件", "CAD图", "dwg", "DialogName", Autodesk.AutoCAD.Windows.OpenFileDialog.OpenFileDialogFlags.AllowMultiple)
  3.         If objOpenFileDialog.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
  4.             '创建文件夹
  5.             Dim myDirectory As String = Path.GetDirectoryName(objOpenFileDialog.Filename)
  6.             Dim newFolder As String = "\转换后"
  7.             If Not Directory.Exists(myDirectory + newFolder) Then
  8.                 Directory.CreateDirectory(myDirectory + newFolder)
  9.             End If
  10.             For i As Integer = 0 To objOpenFileDialog.GetFilenames.Length - 1
  11.                 Try
  12.                     Dim Filename As String = objOpenFileDialog.GetFilenames(i)
  13.                     Dim doc As Document = Application.DocumentManager.Open(Filename, False)
  14.                     '执行命令,接受Document参数。
  15.                     Dim doclock As DocumentLock = doc.LockDocument()
  16.                     pRastIns(Filename)
  17.                     doclock.Dispose()
  18.                     '改文件名
  19.                     Dim newFileName As String = myDirectory + newFolder + "\" + Path.GetFileName(Filename)
  20.                     '存储的文件版本
  21.                     doc.Database.SaveAs(newFileName, DwgVersion.Current)
  22.                     '  ed.WriteMessage("newFileName:<" + newFileName + ">");
  23.                     doc.CloseAndSave(newFileName)
  24.                 Catch ex As Exception
  25.                     ed.WriteMessage(ex.Message)
  26.                 End Try
  27.             Next
  28.         End If
  29.     End Sub


运行有些文件没问题,有些有问题,不知道错在哪里
问题是这句Dim doc As Document = Application.DocumentManager.Open(Filename, False)
cad提示如下:
致命错误:Unhandled Access Violation Reading 0x7efc4134 Exception at 62066e4h

忘高手解决,在线等



发表于 2012-3-29 23:06 | 显示全部楼层
cad 2006 有这个问题,俺也没解决
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-4 18:06 , Processed in 0.298086 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表