Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static void Decompress(FileInfo fileToDecompress, bool overwrite = false)
- {
- if ((File.Exists(fileToDecompress.FullName) && overwrite) ||
- !File.Exists(fileToDecompress.FullName))
- {
- using (FileStream originalFileStream = fileToDecompress.OpenRead())
- {
- string currentFileName = fileToDecompress.FullName;
- string newFileName = currentFileName.Remove(currentFileName.Length - fileToDecompress.Extension.Length);
- using (FileStream decompressedFileStream = File.Create(newFileName))
- {
- using (GZipStream decompressionStream = new GZipStream(originalFileStream, CompressionMode.Decompress))
- {
- decompressionStream.CopyTo(decompressedFileStream);
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment