答案 0 :(得分:6)
使用Process类
答案 1 :(得分:4)
MSDN documentation on Process.StandardOutput文档显示了一个示例
// 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();
您可能也希望提取标准错误流。
答案 2 :(得分:1)
查看流程类Standard Output和Standard Error以及OutputDataReceived和 ErrorDataReceived收到了活动。
有CodeProject article here,您可能会觉得有帮助。