Advertisement
Guest User

Untitled

a guest
Sep 30th, 2014
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.71 KB | None | 0 0
  1. List<string> TextData = new List<string>();
  2.             try
  3.             {
  4.                 using (StreamReader streamReader = new StreamReader(filePath))
  5.                 {
  6.                     string line = streamReader.ReadLine();
  7.                     while (streamReader.Peek() > -1)
  8.                     {
  9.                         TextData.Add(streamReader.ReadLine());
  10.                         streamReader.Close();
  11.                         return TextData;
  12.                     }
  13.                 }  
  14.             }
  15.             catch (Exception e)
  16.             {
  17.                 Console.WriteLine("The file could not be read:");
  18.                 Console.WriteLine(e.Message);
  19.                 return null;
  20.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement