0

I am trying to redirect the output of a c program which generates output in the console. I can redirect the output once the process exits. But is there the way to redirect the output as and when there is some output in the shell window? I require this to make it understandable that the program is running and since different steps of the c code may take, say 10-15 minutes to run.

Thanks in advance for any help.

  • possible duplicate of [Capturing the Console Output in .NET (C#)](http://stackoverflow.com/questions/186822/capturing-the-console-output-in-net-c) – Binary Worrier Dec 18 '10 at 21:12
  • The "Possible Duplicate" question is an exact duplicate. The question is asked for C#, but the links are to MSDN documentation for both C# and Vb.Net – Binary Worrier Dec 18 '10 at 21:12
  • I dont agree that this is a exact duplicate. There is in one hand capturing console out, which works fine for me & i didn't asked for that. What I need is that is there any method which can help me get the output from console as and when they are written in the console or should I have to wait for the process to exit. – user547241 Dec 18 '10 at 21:40

1 Answers1

0

I'm guessing the code that you're using is using ReadToEnd on the StreamReader. If so, just use Read or ReadLine to get access to the stream as its written.

Chris Haas
  • 53,986
  • 12
  • 141
  • 274