I have followed Microsoft's recommended way to unzip a .gz file :
https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.gzipstream?view=netcore-3.1
I am trying to download and parse files from the CommonCrawl. I can successfully download them, and unzip them with 7-zip
However, in c# I get:
System.IO.InvalidDataException: 'The archive entry was compressed using an unsupported compression method.'
public static void Decompress(FileInfo fileToDecompress)
{
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);
Console.WriteLine($"Decompressed: {fileToDecompress.Name}");
}
}
}
}
The file is from there:
Does anyone know what the problem could be? do I need a special library?
I am not sure what the issue is but after reading this post
Decompressing using GZipStream returns only the first line
I changed to SharZipLib (http://www.icsharpcode.net/opensource/sharpziplib/) and it worked