我有以下代码:
var psi = new ProcessStartInfo();
psi.FileName = @"C:\gw\gw.exe";
psi.WorkingDirectory=@"C:\gw";
Process process = Process.Start(psi);
由于某种原因,gw.exe进程在启动时崩溃。 Windows只是说“这个程序已被关闭”并且通常有“在线寻找解决方案”框,它只是崩溃了。
当我从Windows资源管理器启动gw.exe时,它执行得很好。它是一个WPF应用程序,它在我的程序之外运行得很好。有人有什么建议吗?
答案 0 :(得分:1)
您的代码不是启动流程的方式:
Console.WriteLine("Running");
Process pr = new Process();
pr.StartInfo.FileName = "Notepad.exe";
pr.StartInfo.Arguments = "test.dat";
pr.Start();
while (pr.HasExited == false)
if ((DateTime.Now.Second % 5) == 0)
{
// Show a tick every five seconds.
Console.Write(".");
System.Threading.Thread.Sleep(1000);
}
中详细介绍