我在打开图形时遇到了麻烦。我得到的错误说NullReferenceException是未处理的,并突出显示了该路径。任何帮助表示赞赏。由于在C中打开文件路径#
private void button2_Click(object sender, EventArgs e)
{
//Open Solidworks Drawing
ModelDoc2 swModel = default(ModelDoc2);
DocumentSpecification swDocSpecification = default(DocumentSpecification);
string sName = null;
long longstatus = 0;
long longwarnings = 0;
// Drawing document path and name
swDocSpecification = (DocumentSpecification)swApp.GetOpenDocSpec("C:\\location\\????.slddrw");//File Location
sName = swDocSpecification.FileName;
// Sheet name
swDocSpecification.SheetName = "BOM"; //Open to the BOM sheet
swDocSpecification.DocumentType = (int)swDocumentTypes_e.swDocDRAWING;
swDocSpecification.ReadOnly = true;
swDocSpecification.Silent = false;
// Open the specified sheet in the specified drawing document
swModel = swApp.OpenDoc7(swDocSpecification);
longstatus = swDocSpecification.Error;
longwarnings = swDocSpecification.Warning;
}
using SolidWorks.Interop.sldworks; –
什么是通路?为什么你有这样的“文件路径”(或简单的路径):C:\\ location \\ ????。slddrw!? –
我主要想知道我是否正确引用通路 –