Skip to content

Instantly share code, notes, and snippets.

@talkingdotnet
Created February 25, 2018 15:34
Show Gist options
  • Save talkingdotnet/0259175fe56b2ad50e42f77ca333a35f to your computer and use it in GitHub Desktop.
Save talkingdotnet/0259175fe56b2ad50e42f77ca333a35f to your computer and use it in GitHub Desktop.
private void PrepareZip(string filePath)
{
FileInfo gZipfile = new FileInfo(filePath);
FileInfo gzipFileName = new FileInfo(string.Concat(gZipfile.FullName, ".gz"));
using (FileStream fileToBeZippedAsStream = gZipfile.OpenRead())
{
using (FileStream gzipTargetAsStream = gzipFileName.Create())
{
using (GZipStream gzipStream = new GZipStream(gzipTargetAsStream, CompressionMode.Compress))
{
try
{
fileToBeZippedAsStream.CopyTo(gzipStream);
}
catch (Exception ex) { throw ex; }
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment