title: Exit C# Console application when an exception is thrown
body: <p>My code reads text from a file.
  I need to add a method where if the file is not in the correct location, the program will exit.</p>
  
  <pre><code>try {
      TextReader tr = new StreamReader("C:\\textfile.txt");
  
          for (int i = 0; i &lt; 4; i++)
          {
              ListLines[i] = tr.ReadLine();
          }
      }
  catch (Exception e)
      {
      Console.WriteLine("File not found - the app will now exit");
      }
  </code></pre>
  
  <p>Is it possible, and what commands should I use?</p>