//通過此代碼我希望將要執行的批處理文件將顯示shell屏幕上的輸出,我得到RedirectStandardOutput = false;我想同時.RedirectStandardOutput = true/false
但我也希望在同一時間輸出應該重定向到一個日誌文件爲此我必須這樣做RedirectStandardOutput = true;
但一旦一個可以使用,也可以真正或假請幫我很大的編程人員...!
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = "c:\test\build.bat";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.Start();
string output = null;
// try
// {
output = p.StandardOutput.ReadToEnd();
// }
// catch (Exception ex)
// {
// MessageBox.Show(ex.ToString());
// }
System.IO.File.WriteAllText("c:\test\log.txt", output);
這是哪一種語言? C#?請用適當的語言標籤標記它。 – 2010-08-30 12:33:03
請勿標記您的帖子,因爲您需要幫助。它濫用了調節系統。 – Will 2010-08-31 10:10:32