Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2010
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. using System;
  2. using System.IO; // Required to search directories for the .epl files
  3. using System.Collections.Generic;
  4. using System.Text;
  5. using System.Threading;
  6. using System.Globalization;
  7.  
  8. namespace ReadEPL
  9. {
  10. class TextFileReader
  11. {
  12. static void Main(string[] args)
  13. {
  14. Console.WriteLine("Please type the relevent .epl file directory.\n");
  15. string s1;
  16. s1 = Console.ReadLine(); // input appropriate directory
  17. Console.WriteLine("\n");
  18.  
  19. if(Directory.Exists(s1))
  20. {
  21. Console.WriteLine("{0} is a valid file or directory. Searching for .epl file...\n", s1);
  22. // Searches relevant directory for files with said extension, in this case .epl
  23. string[] filePaths = Directory.GetFiles(@s1, "*.txt");
  24.  
  25. if ((filePaths[0]).Length > 1)
  26. {
  27. Console.WriteLine("Found:");
  28. Console.Write(filePaths[0]);
  29. Console.WriteLine("\n");
  30. // Creates text reader instance and opens file, in this case, the .epl file found above
  31. TextReader tr = new StreamReader(filePaths[0]);
  32. // Spits out file contents to console screen
  33. Console.WriteLine(tr.ReadToEnd());
  34. // Closes text reader instance
  35. tr.Close();
  36. } else
  37. {
  38. Console.WriteLine("Pingas");
  39. }
  40. }
  41. else do
  42. {
  43. Console.WriteLine("{0} is not a valid file or directory.\n", s1);
  44. Console.WriteLine("Please type the relevant .epl file directory.\n");
  45. s1 = Console.ReadLine(); // input appropriate directory
  46. Console.WriteLine("\n");
  47. } while(!Directory.Exists(s1));
  48.  
  49. Console.ReadLine();
  50. }
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement