public void SaveBinary(string filename) { using (var stream = new BinaryStream(BufferSize)) { Debug.WriteLine(">> Serializing binary data..."); Serialize(stream); var size = (int)stream.Position; Debug.WriteLine(">> Writing to file..."); stream.WriteFile(filename, size); } }