c# 指定文件打开方式来打开文件 我现在要浏览一张CAD的图,但是我的机子上有两个不同版本的CAD软件,我要指定其中的一个软件来查看该图。因此首先要打开该软件,也就是先打开运行环境,然后再此环境中打开该文件请问该如何去做?我用的是C#语言。因为第一次来,没有什么分,望高手帮帮忙! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 获取软件的路径,把CAD图的路径当作命令行参数,行不行呢如果直接打开CAD图,会以默认的程序打开 if (i == 1) System.Diagnostics.Process.Start(@"Notepad.exe", "e:\\a.txt"); else System.Diagnostics.Process.Start(@"C:\Program Files\Microsoft Office\Office12\WINWORD.EXE", "e:\\a.txt"); 用process.start()在c#中启动你需要的应用程序,然后再在应用程序打开文件 System.Diagnostics.Process.Start(@"C:\Program Files\Microsoft Office\Office12\WINWORD.EXE", "e:\\a.txt");这样就ok了。 关键是我不能把文件的打开方式做死了,客户的机子上有两个不同版本的CAD软件,他需要打开相应的CAD环境来查看相应的图形文件,根据大家的提议,我做的程序如下,望高手指点: 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(); 执行完后,就提示找不到图形文件,其实文件是存在的 timer控件问题 程序运行一会自动退出 表达式异常 c#写了一个windows服务程序,弹出“应用程序生成了一个未未处理的异常” 关于样试表问题? 支持动态图片发送的输入框 窗口继承 获取覆盖图标(overlay icon)的问题。 如何用c#和sql做课程管理系统啊。。 寻求CS项目合伙人,五五分成,预计日收入超万元 c#做图形界面很丰富的应用程序 水晶报表 打开失败!
如果直接打开CAD图,会以默认的程序打开
System.Diagnostics.Process.Start(@"Notepad.exe", "e:\\a.txt");
else
System.Diagnostics.Process.Start(@"C:\Program Files\Microsoft Office\Office12\WINWORD.EXE", "e:\\a.txt");
这样就ok了。
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();
执行完后,就提示找不到图形文件,其实文件是存在的