我的代码是:
Process myProcess = new Process();
myProcess.StartInfo.FileName = @"batchfile.bat";
myProcess.StartInfo.Arguments = "some argument";
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.CreateNoWindow = true;
myProcess.StartInfo.RedirectStandardInput = true;
myProcess.StartInfo.RedirectStandardOutput = true;
myProcess.Start();
StreamReader sr = myProcess.StandardOutput;
textBox1.Text = sr.ReadToEnd();
myProcess.WaitForExit();
它有效,但我想获得异步输出。
谢谢你的帮助。