C# winform 启动外部程序

时间:2022-08-29 00:24:18

//class里面放入这段代码
[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("test.exe"), new StringBuilder(""), new StringBuilder(@"C:\文件夹名"), 1);