Created
February 27, 2018 05:47
-
-
Save talkingdotnet/6574f4262a51e116e1860a65155d54e7 to your computer and use it in GitHub Desktop.
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
private string UnZipFile(string filePath) | |
{ | |
string unZippedFileName = ""; | |
FileInfo fileToDecompress = new FileInfo(filePath); | |
try | |
{ | |
using (FileStream originalFileStream = fileToDecompress.OpenRead()) | |
{ | |
string currentFileName = fileToDecompress.FullName; | |
unZippedFileName = currentFileName.Remove(currentFileName.Length - fileToDecompress.Extension.Length); | |
using (FileStream decompressedFileStream = File.Create(unZippedFileName)) | |
{ | |
using (GZipStream decompressionStream = new GZipStream(originalFileStream, CompressionMode.Decompress)) | |
{ | |
decompressionStream.CopyTo(decompressedFileStream); | |
} | |
} | |
} | |
WriteToConsole("File unzipped successfully."); | |
} | |
catch (Exception ex) | |
{ | |
WriteToConsole("Error: DecompressFile()" + "\n" + ex.ToString()); | |
unZippedFileName = ""; | |
} | |
return unZippedFileName; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment