【发布时间】:2011-09-06 20:16:57
【问题描述】:
代码如下:
ProcessStartInfo startInfo = new ProcessStartInfo("cmd", "/c" + command);
startInfo.CreateNoWindow = true;
startInfo.UseShellExecute = false;
startInfo.WindowStyle = ProcessWindowStyle.Normal;
startInfo.Arguments = arguments;
startInfo.RedirectStandardError = true;
startInfo.RedirectStandardOutput = true;
Process process = Process.start(startInfo);
StreamReader srOutput = process.StandardOutput;
string output = srOutput.ReadToEnd();
命令是rmdir /s /q 123
我希望在变量output 中得到“系统找不到指定的文件”,因为“123”是一个不存在的文件路径。但是output 是一个空字符串。为什么以及如何获取输出?
【问题讨论】:
-
仍有疑问,见下方评论...