我正在使用RedirectStandardOutput从控制台获取“消息”,它正在运行 . 但控制台没有传递“消息”,我希望它出现在控制台上,我也可以在我的程序中操作它们

private void process_OutputCmd(object sender, DataReceivedEventArgs arg)
{
    MessageBox.Show(arg.Data);
}

Process process = new Process();
process.StartInfo.FileName = "cmd.exe";
process.StartInfo.Arguments = "/C ping 127.0.0.1";
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.CreateNoWindow = false;
process.StartInfo.UseShellExecute = false;
process.OutputDataReceived += new DataReceivedEventHandler(process_OutputCmd);
process.Start();
process.BeginOutputReadLine();

enter image description here