Created
July 28, 2016 08:46
-
-
Save jens1101/a4c1f3202d0fa102975bf0dd4560568f to your computer and use it in GitHub Desktop.
Adding files to Gzip in C#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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