【发布时间】:2011-09-19 21:17:06
【问题描述】:
【问题讨论】:
标签: c# .net cmd shell-exec
【问题讨论】:
标签: c# .net cmd shell-exec
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();
您可能还想提取标准错误流。
【讨论】:
查看 Process 类 Standard Output 和 Standard Error,以及 OutputDataReceived 和 ErrorDataReceived 收到事件。
有一个CodeProject article here,您可能会觉得有帮助。
【讨论】:
使用Process 类
【讨论】: