V
vijaynats
Hi
I created a windows app to run a dos batch file (which takes around
5mins to complete and generates lots of output messages on the console
in the meantime)and i used RedirectStandardOuput to display the output
text in a textbox.
The problem is that till the batch file has not finished running i
don't get to see the output in the text box!!
How do we trap the output and display as and when its generated by the
called app? can we get a LIVE UPDATE of the output?
Attached is part of the code for completeness :-
Your help will be greatly appreciated.
Thanks
Vijay
--------- CODE FOLLOWS -------------
// Create Process and Execute
p = new Process();
// Set Start Info
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow=false;
p.StartInfo.RedirectStandardOutput = false;
p.StartInfo.FileName = cmd;
p.StartInfo.WorkingDirectory="C:\\xyz\\";
p.Start();
StreamReader myStreamReader = p.StandardOutput;
// Read the standard output of the spawned process.
while((output = myStreamReader.ReadLine())!=null)
{
this.txtOutput.Text += output + "\r\n";
}
p.Close();
I created a windows app to run a dos batch file (which takes around
5mins to complete and generates lots of output messages on the console
in the meantime)and i used RedirectStandardOuput to display the output
text in a textbox.
The problem is that till the batch file has not finished running i
don't get to see the output in the text box!!
How do we trap the output and display as and when its generated by the
called app? can we get a LIVE UPDATE of the output?
Attached is part of the code for completeness :-
Your help will be greatly appreciated.
Thanks
Vijay
--------- CODE FOLLOWS -------------
// Create Process and Execute
p = new Process();
// Set Start Info
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow=false;
p.StartInfo.RedirectStandardOutput = false;
p.StartInfo.FileName = cmd;
p.StartInfo.WorkingDirectory="C:\\xyz\\";
p.Start();
StreamReader myStreamReader = p.StandardOutput;
// Read the standard output of the spawned process.
while((output = myStreamReader.ReadLine())!=null)
{
this.txtOutput.Text += output + "\r\n";
}
p.Close();