Hey there,
I'm getting the following error when trying to decompress a byte array:
GZipException: GZIP crc sum mismatch, theirs "-1419322270" and ours "574414146
ICSharpCode.SharpZipLib.GZip.GZipInputStream.ReadFooter ()
ICSharpCode.SharpZipLib.GZip.GZipInputStream.Read (System.Byte[ buffer, Int32 offset, Int32 count)
Here's the function that's returning the error:
private const int BUFFER_SIZE = 4096;
public string GetDecompressedJson(byte[ compressedBytes)
{
using (GZipInputStream stream = new GZipInputStream(new MemoryStream(compressedBytes)))
{
byte[ buffer = new byte[BUFFER_SIZE];
using (MemoryStream ms = new MemoryStream())
{
int size = 0;
do
{
size = stream.Read(buffer, 0, BUFFER_SIZE);
if (count > 0)
{
ms.Write(buffer, 0, count);
}
}
while (size > 0);
ms.Position = 0;
StreamReader sr = new StreamReader(ms, Encoding.UTF8);
string json = sr.ReadToEnd();
return json;
}
}
}
The gzip file was made with gzip 1.3.12. Could someone tell me if I'm doing the decompression incorrectly or if there might be something wrong with my gzip file? Using SharpZipLib_0860
Thanks!
bread