Directing Console.Out and Console.Error to a Textbox

  • Thread starter Thread starter Nevyn Twyll
  • Start date Start date
N

Nevyn Twyll

I have a set of libraries that do processing output to Console.Out, and
Console.Error.

How do I direct that output to a Textbox on a Windows form in CSharp?

Thanks in advance!

- Nevyn
 
For this you can route the In, Out, and Error objects used by the
console to your own objects. To do this simply use the Console.SetIn,
Console.SetOut, and Console.SetError equal to your object. SetIn will
accept a text reader while SetOut and SetError take text writers. Once
you've captured the output you can do what you'd like with it. Hope that
helps.

Have A Better One!

John M Deal, MCP
Necessity Software
 
Just a note. The std output can and will stall your process if the std out
fills the stdout stream - which is not a lot of output (maybe a screen
full). So you may need a seperate thread to read process.stdout into your
own output stream until process done.
 
Back
Top