Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Text;
- class ReadATextAndPrintIt
- {
- public static void Main()
- {
- try
- {
- Console.WriteLine("Enter the full path to file you want to write on console:");
- string path = Console.ReadLine();
- string readText = File.ReadAllText(path);
- Console.WriteLine(readText);
- }
- catch (ArgumentException)
- {
- Console.WriteLine("Wrong path is entered.");
- }
- catch (DirectoryNotFoundException)
- {
- Console.WriteLine("Can't find the file directory.");
- }
- catch (IOException)
- {
- Console.WriteLine("Problem occures while opening file. Or file is not found.");
- }
- catch (UnauthorizedAccessException)
- {
- Console.WriteLine("You have no permision to open the file or a directory.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement