Reputation: 1188
I want to decompress a zip file.
The code that I used is so simple.
I could not understand why I' m getting this error;
The magic number in GZip header is not correct. Make sure you are passing in a GZip stream.
public static void Decompress(Stream fileToDecompress)
{
using (FileStream decompressedFileStream = File.Create("BinaryTest"))
{
using (GZipStream decompressionStream = new GZipStream(fileToDecompress, CompressionMode.Decompress))
{
decompressionStream.CopyTo(decompressedFileStream); **Error**
}
}
}
Upvotes: 0
Views: 1679
Reputation: 112502
gzip is not zip. zip is not gzip. You can use the ZipFile class or DotNetZip to extract a zip file.
Upvotes: 1
Reputation: 19828
Did you check if fileToDecompress
is proper GZipStream? You can copy it locally to file and check if it is valid. The error show clean that data in the stream is not valid.
Upvotes: 0