1

我在 C# 中有以下应用程序。我所期待的是它会打开 calc.exe,等待我手动关闭它(控制台会挂起),然后它最终会退出。但它会打开 calc.exe 并退出(而 calc 仍处于打开状态)。我错过了什么?

class Program
{
     static void Main(string[] args)
     {
         Process p2 = new Process();
         p2.StartInfo.UseShellExecute = false;
         p2.StartInfo.RedirectStandardError = true;
         p2.StartInfo.FileName = "calc.exe";
         p2.Start();
         string error = p2.StandardError.ReadToEnd();
         p2.WaitForExit();
         Console.WriteLine("done");
    }
}

从这里复制的代码。

4

0 回答 0