Posted By

kirilstanoev on 09/28/11


Tagged


Versions (?)

Reading a Text File Line by Line


 / Published in: C#
 

URL: http://msdn.microsoft.com/en-us/library/aa287535%28v=vs.71%29.aspx

  1. // create reader & open file
  2. TextReader tr = new StreamReader("SomeFile.txt");
  3.  
  4. string line = "EMPTY LINE";
  5. while ((line = tr.ReadLine()) != null)
  6. {
  7. Console.WriteLine(line);
  8. }
  9.  
  10. // close the stream
  11. tr.Close();

Report this snippet  

You need to login to post a comment.