1 out of 2 rated this helpful - Rate this topic

File.ReadAllLines Method

Opens a text file, reads all lines of the file into a string array, and then closes the file.

This member is overloaded. For complete information about this member, including syntax, usage, and examples, click a name in the overload list.

  Name Description
Public method Static member ReadAllLines(String) Opens a text file, reads all lines of the file, and then closes the file.
Public method Static member ReadAllLines(String, Encoding) Opens a file, reads all lines of the file with the specified encoding, and then closes the file.
Top
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Alernative in .net 4: ReadLines
In .net 4.0 you can also use File.ReadLines to lazily read the file. This has the advantage that the file doesn't need to be held in memory completely, but only the current line. This is mainly relevant when reading large files.