NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Reading and Writing to a Newly Created Data File

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() );
  }