Home
Manage Your Code
Snippet: Read file with each line (C#)
Title: Read file with each line Language: C#
Description: Read file with StreamReader Views: 116
Author: Yan Xing Yang Date Added: 7/31/2008
Copy Code  
1            using (System.IO.StreamReader sr = new System.IO.StreamReader(strFileName))
2            {
3                String line;
4                // Read and display lines from the file until the end of 
5                // the file is reached.
6                while ((line = sr.ReadLine()) != null)
7                {
8                    Console.WriteLine(line);
9                }
10            }
11