C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
C# program that uses StreamReader ReadToEnd
using System;
using System.IO;
class Program
{
static void Main()
{
using (StreamReader reader = new StreamReader(@"C:\programs\file.txt"))
{
// Read entire text file with ReadToEnd.
string contents = reader.ReadToEnd();
Console.WriteLine(contents);
}
}
}
Output
Thank you
Friend
However: In other programs, where no StreamReader object exists, File.ReadAllText is probably a clearer method to use.