Construct StreamWriter from FileSream : Stream Read Write : File Stream C# Source Code


Custom Search

C# Source Code » File Stream » Stream Read Write »

 

Construct StreamWriter from FileSream








    


using System;
using System.IO;

public class IOExample
{
  static void Main() {   
    FileStream fs;
    StreamWriter sw;


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

      // write a line to the file
      string newLine = "Not so different from you and me";
      sw.WriteLine(newLine);

      // close the streams
      sw.Close();
      fs.Close();
    } catch (IOException ioe) {
      Console.WriteLine("IOException occurred: "+ioe.Message);
    }
  }
}

           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo File Stream
» Stream Read Write