How To Read Entire Text File



TODO:

Have you ever wanted to read the contents of a text file in C#?

 

SOLUTION:

string filedata = "";
string inFileName = "C:\\test.txt";

using (StreamReader sr = new StreamReader(inFileName))
{
     filedata = sr.ReadToEnd();
}

 

NOTES:

There are no notes on this topic.



Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading