-
Process input/output
having a bit of trouble here.
I want to redirect input from my keyboard or rather from a textbox into the Process I am running.
I have been able to successfully, I think, redirect output from a console application using the Process/ProcessStartInfo, into a textbox but now I want to redirect my inputs with that process. How can I do this?
So far the only code I have is to redirect output from the application to the textbox, not even sure if its right:
Code:
Process theProcess = new Process();
theProcess.StartInfo = new ProcessStartInfo("cmd");
theProcess.StartInfo.UseShellExecute = false;
theProcess.StartInfo.RedirectStandardOutput = true;
theProcess.StartInfo.RedirectStandardInput = true;
theProcess.OutputDataReceived += new DataReceivedEventHandler(theProcess_OutputDataReceived);
theProcess.Start();
theProcess.BeginOutputReadLine();
void theProcess_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
if (e.Data != null)
{
this.txtOutput.AppendText(e.Data);
}
}