This example shows the basics of creating a file stream, creating the associated BinaryReader and BinaryWriter, and doing some file I/O.
FileStream fs = new FileStream("data.txt", FileMode.CreateNew); BinaryWriter w = new BinaryWriter(fs); BinaryReader r = new BinaryReader(fs); for (int i = 0; i < 11; i++) { w.Write( (int) i); } //Set the file pointer to the beginning. w.GetStream().Seek(0,SeekOrigin.Begin); for (int i = 0; i < 11; i++) { Console.WriteLine( r.ReadInt32() ); }