How to Read Text File in .NET


If you want to read a text file in .NET application without worrying about .NET IO Streams, Readers or EOF markers you can use utility methods available of File class. One of such method is ReadAllText which returns all contents as string.

string fileContents = File.ReadAllText("C:\\MyFile.txt");

 

 

About author


User avatar

Waqas Anwar

Founder of EzzyLearning.com, Senior Consultant, Microsoft .NET and Web Technologies

Add Comment