我正在运行应用A并使用流程启动启动另一个应用B.我有可能获得应用B的跟踪信息吗?
答案 0 :(得分:1)
您可以捕获StandardOutput。来自MSDN documentation:
// 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
),您可以捕获刚刚启动的流程的输出。