using System.Diagnostics;
Process exep = new Process(); //创建一个进程
exep.StartInfo.FileName = "calc.exe";//启动程序
exep.StartInfo.Arguments = "";//附加参数
FileInfo info = new FileInfo("d:\\test\\my.txt");
exep.StartInfo.WorkingDirectory = info.Directory.ToString(); //工作路径 d:\\test
exep.StartInfo.CreateNoWindow = false;
exep.StartInfo.UseShellExecute = true;
exep.Start();
// exep.WaitForExit() ();//关键,等待外部程序退出后才能往下执行
//int ec = exep.ExitCode;【语言-c#】C# 启动exe
最新推荐文章于 2025-04-10 11:55:20 发布
本文介绍如何使用C#来启动外部程序,并设置程序的工作目录、附加参数等配置。此外,还介绍了如何让当前程序等待外部程序执行完毕。
721

被折叠的 条评论
为什么被折叠?



