嘿,我实际上有两个问题。当我使用process.StandardError时,我得到的结果与使用process.StandardOutput时的结果相同。为什么会这样?
另外,当我使用process.StandardError时,它被写入控制台窗口,而当我使用process.StandardOutput时,它被写入我的buglist.txt。有什么建议么?
//Make Screenshot of Client Setup
OutputHandler.ColorCMDOutput(" + Make a Screenshot",
ConsoleColor.Gray);
Process makeScreenshot = new Process();
makeScreenshot.StartInfo.FileName = screenShotTool;
makeScreenshot.StartInfo.Arguments = "/f \"" + testResult + "\\Screenshots\\" + screenShotName + ".png\"";
makeScreenshot.StartInfo.UseShellExecute = false;
makeScreenshot.StartInfo.RedirectStandardError = true;
makeScreenshot.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
makeScreenshot.Start();
//Start StreamReader
StreamReader myStreamReader = makeScreenshot.StandardError;
string error = makeScreenshot.StandardError.ReadToEnd();
//Read the standard error
OutputHandler.AppendDataToFile(buglist, error);
makeScreenshot.WaitForExit();
makeScreenshot.Dispose();