StreamWriter and BinaryWriter : Binary Read Write : File Stream C# Source Code


Custom Search

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

 

StreamWriter and BinaryWriter








    
 
using System;
using System.IO;

class BinReadWriteApp
{
    static void Main(string[] args)
    {
        Stream s = new FileStream("Foo.txt", FileMode.Create);
        StreamWriter w = new StreamWriter(s);
        w.Write("Hello World ");
        w.Write(123);
        w.Write(' ');
        w.Write(45.67);
        w.Close();
        s.Close();
   
        Stream t = new FileStream("Bar.dat", FileMode.Create);
        BinaryWriter b = new BinaryWriter(t);
        b.Write("Hello World ");
        b.Write(123);
        b.Write(' ');
        b.Write(45.67);
        b.Close();
        t.Close();
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo File Stream
» Binary Read Write