代码如下:
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();
Run Code Online (Sandbox Code Playgroud)
命令是 rmdir /s /q 123
我希望在变量中找到"系统找不到指定的文件",output因为"123"是不存在的文件路径.但是output是一个空字符串.为什么以及如何获得输出?