title: How to save our actions on a console window into a text file?
body: <p>If we compile the following code and run the resulting application, we will interact with it by entering our name, pressing enter, and pressing any key to exit. All of these actions are done on a console window.</p>
  
  <pre><code>using System;
  
  namespace HelloWorld
  {
      class Program
      {
  
          static void Main(string[] args)
          {
              Console.Write("Enter your name: ");
              var name = Console.ReadLine();
              Console.WriteLine("Your name is {0} ", name);
              Console.ReadKey();
  
          }
      }
  }
  </code></pre>
  
  <p>Is it possible to save all of these actions to a text file such that I can make use of it as a log?</p>
  
  <p>Edit:</p>
  
  <p>I should explain the real scenario. I am writing a book about C#. I want to avoid attaching the screen shot of the console window to the book because I want to make the file size of my book as small as possible. Instead, I want to attach a text file showing the content of console window to the book. Adding additional code (for creating the text file) will complicate the code example, which in turn will make the reader get confused.</p>