Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO; // Required to search directories for the .epl files
- using System.Collections.Generic;
- using System.Text;
- using System.Threading;
- using System.Globalization;
- namespace ReadEPL
- {
- class TextFileReader
- {
- static void Main(string[] args)
- {
- Console.WriteLine("Please type the relevent .epl file directory.\n");
- string s1;
- s1 = Console.ReadLine(); // input appropriate directory
- Console.WriteLine("\n");
- if(Directory.Exists(s1))
- {
- Console.WriteLine("{0} is a valid file or directory. Searching for .epl file...\n", s1);
- // Searches relevant directory for files with said extension, in this case .epl
- string[] filePaths = Directory.GetFiles(@s1, "*.txt");
- if ((filePaths[0]).Length > 1)
- {
- Console.WriteLine("Found:");
- Console.Write(filePaths[0]);
- Console.WriteLine("\n");
- // Creates text reader instance and opens file, in this case, the .epl file found above
- TextReader tr = new StreamReader(filePaths[0]);
- // Spits out file contents to console screen
- Console.WriteLine(tr.ReadToEnd());
- // Closes text reader instance
- tr.Close();
- } else
- {
- Console.WriteLine("Pingas");
- }
- }
- else do
- {
- Console.WriteLine("{0} is not a valid file or directory.\n", s1);
- Console.WriteLine("Please type the relevant .epl file directory.\n");
- s1 = Console.ReadLine(); // input appropriate directory
- Console.WriteLine("\n");
- } while(!Directory.Exists(s1));
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement