Zoo tutorials: [ SQL | Linux | XML ]
ProgZoo: [ Java | C# | VB | C++ | Perl ]
Log in

A Gentle Introduction to
C# Programming

Read a Text File

 

Top Ten Programs

Read a Text File
You can open a text file and read each line.

1. [ C# ] Reading lines


Big

The text file haggis.txt includes some lines of text.

  • The StreamReader represents a text file that can process one line at a time.
  • We use the ReadLine method to obtain a single line of text.
  • When the file has been exhausted the string returned will be null.