代码如下:
命令是
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
中得到 "The system cannot find the file specified",因为 "123" 是一个不存在的文件路径。但实际上 output
是一个空字符串。为什么会这样,我该如何获取输出结果?