using System; using System.Windows.Forms; using acWin = Autodesk.AutoCAD.Windows; using acApp = Autodesk.AutoCAD.ApplicationServices.Application; using Autodesk.AutoCAD.Runtime; using Autodesk.AutoCAD.ApplicationServices; namespace OpenSaveFile { public class Class1 { [CommandMethod("OpenSaveFile")] public void OpenSaveFile() { // 调用标准多文件选择对话框 acWin.OpenFileDialog dwgsForm = new acWin.OpenFileDialog("打开多个图形文件", "", "dwg", "", acWin.OpenFileDialog.OpenFileDialogFlags.AllowMultiple); // 如是取消了 if (dwgsForm.ShowDialog() != DialogResult.OK) return; // 取得多文件数组 string[] dwgfiles = dwgsForm.GetFilenames(); // 遍历文件数组 for (int i = 0; i < dwgfiles.GetLength(0); i++) { // 打开DWG文件 Document oDoc = acApp.DocumentManager.Open(dwgfiles[i], false); // // 执行其它动作 // // 关闭文件并放弃保存 oDoc.CloseAndDiscard(); } } } }