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.
try {
TextReader tr = new StreamReader("C:\\textfile.txt");
for (int i = 0; i < 4; i++)
{
ListLines[i] = tr.ReadLine();
}
}
catch (Exception e)
{
Console.WriteLine("File not found - the app will now exit");
}
Is it possible, and what commands should I use?