This code writes down MemoryStream to a file:
FileStream file =newFileStream("file.bin",FileMode.Create,System.IO.FileAccess.Write); byte[] bytes =newbyte[ms.Length]; ms.Read(bytes,0,(int)ms.Length); file.Write(bytes,0, bytes.Length); file.Close(); ms.Close();
and this reads a file to a MemoryStream :
MemoryStream ms =newMemoryStream();
FileStream file =newFileStream(