How do I output the entire contents of the Console window to a Text file when I'm done with it? I've tried searching for this but all I have come up with is a method to write the stream to a TextBox but I think that's a bit overkill, right?
Asked
Active
Viewed 444 times
0
-
Its simple to use a `TraceListener` to write to the console and a (buffered) file simultaneously – Alex K. Dec 03 '14 at 11:53
-
Look in here: http://stackoverflow.com/questions/4470700/how-to-save-console-writeline-output-to-text-file – Darien Pardinas Dec 03 '14 at 11:53
-
Inject your own `TextWriter` to `Console.Out` using `Console.SetOut` – Sriram Sakthivel Dec 03 '14 at 11:53
1 Answers
3
You could simply redirect the output of your console application to a file from a command prompt like this
myApplication.exe > log.txt
EDIT: On linux you could use the "tee" command (allows you to both display the output of the application and redirect it to a file); you might be able to find a Windows implementation for that command but I haven't used one myself

Stefan Ch
- 329
- 2
- 7