Pergunta

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.

Foi útil?

Solução

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top