110,534
社区成员
发帖
与我相关
我的任务
分享
Console.WriteLine("控制台内容1 >>>");
Console.WriteLine("控制台内容2 >>>");
private void Form1_Load(object sender, EventArgs e)
{
Process Processer = new Process();
Processer.StartInfo.FileName = "";
Processer.StartInfo.RedirectStandardOutput = true;
Processer.StartInfo.RedirectStandardInput = true;
Processer.StartInfo.RedirectStandardError = true;
Processer.StartInfo.UseShellExecute = false;
Processer.Start();
Processer.BeginOutputReadLine();
Processer.OutputDataReceived+=ConsoleOutput;
}
public void ConsoleOutput(object sender,DataReceivedEventArgs e)
{
if (!string.IsNullOrEmpty(e.Data))
{
//e.Data就是输出的内容
}
}