Possible Duplicate:
Mirroring console output to a file
I've a console application in C# and I want to Log into a text file every text appears on the screen. How to do that ?
Unfortunately this thread is closed despite of my comment about the Mirroring console output to a file. The accepted post as answer by that thread IS NOT CORRECT. So why cannot ask the question again? I'm using console interactively and want a copy of all the text on console in a text file. SOS
WriteLine(sRes); SW. Close(); Console. WriteLine("File Created"); reader. Close();
To redirect the output of a command to a file, type the command, specify the > or the >> operator, and then provide the path to a file you want to the output redirected to. For example, the ls command lists the files and folders in the current directory.
You can use the tee command to output text from a command both to the screen and to a file. The tee command takes data from standard input and writes it to standard output as well as to a file.
C:\>yourconsoleapp.exe > yourtextfile.txt
edit: This assumes your console app requires no user input.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With