read from a text file - CSharp File IO

CSharp examples for File IO:Text File

Description

read from a text file

Demo Code

using static System.Console;
using static System.IO.Directory;
using static System.IO.Path;
using static System.Environment;
using System.IO;// w w w. j  a  va  2s  .c  om
class Program
{
   static void Main(string[] args)
   {
      WriteLine($"Reading contents of {"backupFile"}:");
      StreamReader textReader = File.OpenText("backupFile");
      WriteLine(textReader.ReadToEnd());
      textReader.Close();
   }
}

Result


Related Tutorials