I am very sorry for the conservative title and the question itself, but I was lost.
Samples provided using ICsharpCode.ZipLib do not include what I'm looking for. I want to unzip byte [] by putting it in InflaterInputStream (ICSharpCode.SharpZipLib.Zip.Compression.Streams.InflaterInputStream)
I found the decompress function, but it does not work.
public static byte[] Decompress(byte[] Bytes) { ICSharpCode.SharpZipLib.Zip.Compression.Streams.InflaterInputStream stream = new ICSharpCode.SharpZipLib.Zip.Compression.Streams.InflaterInputStream(new MemoryStream(Bytes)); MemoryStream memory = new MemoryStream(); byte[] writeData = new byte[4096]; int size; while (true) { size = stream.Read(writeData, 0, writeData.Length); if (size > 0) { memory.Write(writeData, 0, size); } else break; } stream.Close(); return memory.ToArray(); }
It throws an exception in the string (size = stream.Read (writeData, 0, writeData.Length);) says that it has an invalid header.
My question is not how to fix this function, this function is not provided in the library, I just found it googling. My question is how to unpack the same as a function with InflaterStream, but without exceptions.
Thanks and again - sorry for the conservative question.
source share