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**
}
}
}
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.