我用了 System.Diagnostics.Process.Start(exepath,exefile);
其中exepath是执行程序的绝对路径,exefile是文件的路径,可执行时CAD的运行环境是打开了,但是提示找不到指定的图形文件,这是什么问题啊?望高手赐教,该问
其中exepath是执行程序的绝对路径,exefile是文件的路径,可执行时CAD的运行环境是打开了,但是提示找不到指定的图形文件,这是什么问题啊?望高手赐教,该问
请高手赐教!很急
你先CMD里试试啊,不是有值就能用的,有可能exepath根本不接收exefile这个参数,所以你传进去也是没用的
另外,还有一种方法,就是修改注册表,把exepath这个软件作为.dwg后缀的默认打开软件
HKEY_CLASSES_ROOT\.dwg
我给你个例子,比如 我的 e:\a.txt 我可以默认记事本打开
System.Diagnostics.Process.Start(@"e:\a.txt");
也可以用word打开
System.Diagnostics.Process.Start(@"C:\Program Files\Microsoft Office\Office12\WINWORD.EXE" ,@"e:\a.txt");你去试试.应该可以的.
在程序中测试也没有问题System.Diagnostics.Process.Start(@"c:\program files\autocad 2004\acad.exe", @"d:\test.dwg"); 你还是检查一下程序吧,主要是文件路径是否写正确
我试了试也是不行。
是在不可以就设置他的默认启动项为CAD,然后只写打开文件名参数,不要写CAD的文件路径了
在运行--》Command可以看到
string exefile = di + "\\" + filename;/////需要查看的文件(例如:C:\Documents and Settings\ww\Local Settings\Temp\Test\CAD.dwg)
this.openFileDialog1.InitialDirectory = "c:\\";
this.openFileDialog1.ShowDialog();
string exepath = "";
if (this.openFileDialog1.FileName.Length > 0)
exepath = this.openFileDialog1.FileName;//////选择的执行程序(例如:D:\Program Files\AutoCAD 2004\acad.exe)
Process myprocess = new Process();
myprocess.StartInfo.Verb = "Open";
myprocess.StartInfo.FileName = exepath.Trim();
myprocess.StartInfo.CreateNoWindow = true;
myprocess.StartInfo.Arguments = exefile.Trim();
myprocess.Start();
执行完后,就提示找不到图形文件,其实文件是存在的
string exefile = di + "\\" + filename;/////需要查看的文件(例如:C:\Documents and Settings\ww\Local Settings\Temp\Test\CAD.dwg)
this.openFileDialog1.InitialDirectory = "c:\\";
this.openFileDialog1.ShowDialog();
string exepath = "";
if (this.openFileDialog1.FileName.Length > 0)
exepath = this.openFileDialog1.FileName;//////选择的执行程序(例如:D:\Program Files\AutoCAD 2004\acad.exe)
Process myprocess = new Process();
myprocess.StartInfo.Verb = "Open";
myprocess.StartInfo.FileName = exepath.Trim();
myprocess.StartInfo.CreateNoWindow = true;
myprocess.StartInfo.Arguments = exefile.Trim();
myprocess.Start();
执行完后,就提示找不到图形文件,其实文件是存在的
在 Windows 桌面环境中是通过将路径包围在双引号中来解决该问题的,不知道通过编程的方式是否可行。
比如:string filename = "\"C:\\Some Path\\file.ext\"";