1

我正在运行一个应用程序 A,它使用进程启动启动另一个应用程序 B。我可以获取应用 B 的跟踪信息吗?

4

1 回答 1

1

您可以捕获标准输出。从MSDN 文档

// Start the child process.
 Process p = new Process();
 // Redirect the output stream of the child process.
 p.StartInfo.UseShellExecute = false;
 p.StartInfo.RedirectStandardOutput = true;
 p.StartInfo.FileName = "Write500Lines.exe";
 p.Start();
 // Do not wait for the child process to exit before
 // reading to the end of its redirected stream.
 // p.WaitForExit();
 // Read the output stream first and then wait.
 string output = p.StandardOutput.ReadToEnd();
 p.WaitForExit();

因此,通过阅读StandardOutput(和/或StandardError),您可以捕获刚刚启动的进程的输出。

于 2013-02-25T07:51:09.170 回答