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

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 966,155 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
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.

Oldest comments (0)

🌚 Friends don't let friends browse without dark mode.

Sorry, it's true.