How can I redirect whatever is written to the console to be written into a string?
Asked
Active
Viewed 2,483 times
3 Answers
18
For your own process, Console.SetOut
and redirect it to a TextWriter built on top of a string builder or memory stream. For a launched child process, use ProcessStartInfo.RedirectStandardOutput
when launching the process.

Remus Rusanu
- 288,378
- 40
- 442
- 569