string command = "/c " + richTextBox2.Text; ProcessStartInfo procStartInfo = new ProcessStartInfo("CMD", command); Process proc = new Process(); proc.StartInfo = procStartInfo; // proc.Start(); procStartInfo.RedirectStandardOutput = true; procStartInfo.UseShellExecute = false; proc.OutputDataReceived += new DataReceivedEventHandler(proc_OutputDataReceived); proc.Start(); proc.BeginOutputReadLine(); proc.WaitForExit();
void proc_OutputDataReceived(object sender, DataReceivedEventArgs e) { if (e.Data != null) { string newLine = e.Data.Trim() + Environment.NewLine; // MethodInvoker append = () => richTextBox1.Text += newLine; MethodInvoker append = () => richTextBox1.AppendText(newLine); richTextBox1.BeginInvoke(append); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)