Create StreamReader from File Stream

image_pdfimage_print
   


using System;
using System.IO;

public class IOExample
{
  static void Main() {   
    FileStream fs;
    StreamReader srIn;

    try {
      fs = new FileStream("practice.txt", FileMode.Open );
      srIn = new StreamReader(fs);

      string line = srIn.ReadLine();

      Console.WriteLine("line = "+line);
      srIn.Close();
    } catch (IOException ioe) {
      Console.WriteLine("IOException occurred: "+ioe.Message);
    }
  }
}

           
          


This entry was posted in File Stream. Bookmark the permalink.