Code Snippets

Snippets that use the System.IO namespace:
Read contents of a file with TextReader

VB.NET
   1:  Dim tr As TextReader = File.OpenText("C:\temp\somefile.txt")
   2:  Console.Write(tr.ReadToEnd())
   3:  tr.Close()
C#
   1:  TextReader tr = File.OpenText(@"C:\temp\somefile.txt");
   2:  Console.Write(tr.ReadToEnd());
   3:  tr.Close();