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();
}
}
Related examples in the same category