Skip to content

Instantly share code, notes, and snippets.

@jens1101
Created July 28, 2016 08:46
Show Gist options
  • Select an option

  • Save jens1101/a4c1f3202d0fa102975bf0dd4560568f to your computer and use it in GitHub Desktop.

Select an option

Save jens1101/a4c1f3202d0fa102975bf0dd4560568f to your computer and use it in GitHub Desktop.
Adding files to Gzip in C#
public static void Compress(FileInfo fileToCompress)
{
var bytes = File.ReadAllBytes(fileToCompress.FullName);
using (FileStream fs = new FileStream(fileToCompress.FullName + ".gzip", FileMode.CreateNew))
using (GZipStream zipStream = new GZipStream(fs, CompressionMode.Compress, false))
{
zipStream.Write(bytes, 0, bytes.Length);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment