문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top