DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Joe Enos
Joe Enos

Posted on

C# Line Reader

One of the most common tasks I've done over the years is just reading a plain text file - whether it's part of a full import process, or a one time job to clean up a file.

With .NET, it's really easy to loop line-by-line through a file. The StreamReader class can read lines, handling all of the nonsense like line break types.

Here's the easiest way to read and handle a text file. There's actually a faster way, File.ReadAllLines, but that doesn't handle large files well. The StreamReader does.

Top comments (0)

πŸ€” Did you know?

Β 
✍️ Writing your own article is easy (we even support markdown).