Posted By

Verician on 09/26/12


Tagged

file text read streamReader


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

Priestd09
danfinrud55


Read From Text File C#


 / Published in: C#
 

Read from a text file using a stream reader in C#

  1. List<string> lines = new List<string>();
  2.  
  3. using (StreamReader r = new StreamReader("databasefile.txt"))
  4. {
  5. string line;
  6. while ((line = r.ReadLine()) != null)
  7. {
  8. lines.Add(line);
  9. }
  10. r.Close();
  11. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: Verician on September 26, 2012

Make sure to include using statements:

using System.Text; using System.IO;

You need to login to post a comment.