
提供两种实现方法
1、
System.Diagnostics.ProcessStartInfo Process= new System.Diagnostics.ProcessStartInfo();
//设置要调用的外部程序名
Info.FileName = "notepad.exe";
//设置外部程序的启动参数(命令行参数)为1.txt
Info.Arguments = "1.txt";
//设置外部程序工作目录为 C:\
Info.WorkingDirectory = "C:\\";
Process.Start();
2、
第一步,申明要调用的系统的API
[DllImport("shell32.dll")]
public static extern int
ShellExecute(IntPtr hwnd,StringBuilder lpszOp,StringBuilder
lpszFile,StringBuilder lpszParams,StringBuilder lpszDir,int FsShowCmd);
//放在方法外面,方法的申明
调用
ShellExecute(IntPtr.Zero,new StringBuilder("Open"),new
StringBuilder("notepad"),new StringBuilder(""),new StringBuilder(@"C:"),
1);
还有要导入命名空间:using System.Runtime.InteropServices;