I have a Console application (C#) that interacts with the User, and every step is shown via Console.Writeline.
Now I wanted to write these events to XML or TXT, and my only guess was to create a List and add all the Console.Writelines to it, but then I noticed that logging the Console.Readline is mandatory, and that’s the reason I’m asking this question.
How do I log Console.Reads/Console.Writes to a TXT/XML?
Thank you.
The simplest way to accomplish this is to use File.AppendAllText
Something like this
If you would prefer to gather all of the text first and then write it all out when your program exits, you could do something like this:
See
http://msdn.microsoft.com/en-us/library/92e05ft3