1
下面的代碼是一個正常的控制檯應用程序工作的偉大:爲什麼Process.OutputDataReceived在ASP.NET中不起作用,我該如何解決它?
private void button1_Click(object sender, EventArgs e)
{
Process process = new Process();
process.StartInfo.FileName = @"a.exe";
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.UseShellExecute = false;
process.OutputDataReceived += new DataReceivedEventHandler(process_OutputDataReceived);
process.Start();
process.BeginOutputReadLine();
}
void process_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
this.Invoke(new Action(delegate() { textBox2.Text += "\r\n" + e.Data; }));
}
,但在Web應用程序,它啓動「a.exe的」,但這麼想的輸出到文本框。我該如何解決它?謝謝。