Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
GZIP writing example
byte[] buffer;
using (FileStream fileStream = new FileStream(@"c:\out.html", FileMode.Open))
// Read the file's contents into a byte array
buffer = new byte[fileStream.Length];
fileStream.Read(buffer, 0, buffer.Length);
using (MemoryStream memoryStream = new MemoryStream())
// The GZipStream uses the MemoryStream to write its compressed version
// of the byte array.
using (GZipStream gzipStream = new GZipStream(memoryStream, CompressionMode.Compress, true))
gzipStream.Write(buffer, 0, buffer.Length);
// Write back to a file.
using (FileStream fileStreamOut = new FileStream(@"c:\", FileMode.Create))
You can’t perform that action at this time.