Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- namespace ConsoleTests
- {
- class ConsoleTests
- {
- static void Main()
- {
- ReadTxt(Console.ReadLine());
- Console.ReadKey();
- }
- private static void ReadTxt(string filename)
- {
- try
- {
- using (StreamReader sr = File.OpenText(filename))
- {
- string s = sr.ReadToEnd();
- Console.WriteLine(s);
- }
- }
- catch (FileNotFoundException notFound)
- {
- Console.WriteLine(notFound.Message);
- }
- catch (IOException masterError)
- {
- Console.WriteLine("Error!");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment