Question

I'm trying to decompress a byte array. Because I want to extract a .png file from a zip.

I tried this:

var compressedData = ZlibStream.UncompressBuffer(cByteArray);

var uncompressedData = ZlibStream.CompressBuffer(compressedData);   

using(FileStream fs = new FileStream(@"F:\picture.png", FileMode.Create)){

fs.Write(uncompressedData, 0, uncompressedData);
}

But got the following error: Bad state (unknown compression method (0x5C))

So can anyone help me out on how to get the file from the data. The compressed data is from a zip file entry. So the header is excluded.

Était-ce utile?

La solution

Use DeflateStream, not ZlibStream. The former processes raw deflate data as wrapped in zip files. The latter processes zlib streams, which is deflate data with a zlib wrapper.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top