Skip to content

Instantly share code, notes, and snippets.

@tiernano
Created December 12, 2012 11:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tiernano/4267147 to your computer and use it in GitHub Desktop.
Save tiernano/4267147 to your computer and use it in GitHub Desktop.
convert the object (obj) into a serialized protobuf object, compress and then write to tmpFile
using (MemoryStream serialized = new MemoryStream())
{
Serializer.Serialize(serialized, obj);
byte[] data = serialized.ToArray();
using (FileStream fs = new FileStream(tmpFile, FileMode.Create))
{
using (GZipStream zip = new GZipStream(fs, CompressionMode.Compress))
{
zip.Write(data, 0, data.Length);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment