-
-
Notifications
You must be signed in to change notification settings - Fork 346
Open
Description
I was unable to get ExtractGZipToDirectory() working. It just created an empty file when I tried to decompress it. I ended up creating this method which did work:
private static FileInfo DecompressGZipFile(this FileInfo compressedFilePath)
{
using (var fs = compressedFilePath.OpenRead())
{
using (var zipStream = new GZipStream(fs, CompressionMode.Decompress))
{
var buffer1 = compressedFilePath.Name.Split('.');
var buffer2 = buffer1[0] + "." + buffer1[1];
var filePath = Path.Combine(compressedFilePath.DirectoryName, buffer2);
using (var fOutStream = new FileStream(filePath, FileMode.Create, FileAccess.Write))
{
var tempBytes = new byte[4096];
int i;
while ((i = zipStream.Read(tempBytes, 0, tempBytes.Length)) != 0)
{
fOutStream.Write(tempBytes, 0, i);
}
}
return new FileInfo(filePath);
}
}
}
Metadata
Metadata
Assignees
Labels
No labels