I have some base-64 encoded zlib data that I'm trying to uncompress into its original string. The following code works fine to do this on .NET Framework 4.8.
string base64 = "eJzzSM3JyVcozy/KSVEEAB0JBF4=";
byte[] bytes = Convert.FromBase64String(base64);
string output;
using (MemoryStream stream = new MemoryStream(bytes))
{
using (GZipStream gZipStream = new GZipStream(stream, CompressionMode.Decompress))
{
using (StreamReader reader = new StreamReader(gZipStream))
output = reader.ReadToEnd();
}
}
Console.WriteLine(output);
The expected output here is "Hello world!" as a test string. The code, however, fails on .NET Core 2.1 with the following exception:
System.IO.InvalidDataException: The archive entry was compressed using an unsupported compression method. at System.IO.Compression.Inflater.Inflate(FlushCode flushCode) at System.IO.Compression.Inflater.ReadInflateOutput(Byte* bufPtr, Int32 length, FlushCode flushCode, Int32& bytesRead) at System.IO.Compression.Inflater.InflateVerified(Byte* bufPtr, Int32 length) at System.IO.Compression.DeflateStream.ReadCore(Span`1 buffer) at System.IO.Compression.DeflateStream.Read(Byte[] array, Int32 offset, Int32 count) at System.IO.Compression.GZipStream.Read(Byte[] array, Int32 offset, Int32 count) at System.IO.StreamReader.ReadBuffer() at System.IO.StreamReader.ReadToEnd()
The documentation doesn't state, that I can find, on why .NET Core would not be compatible with the zlib format used here.
Is the implementation in Core different somehow? Is it missing entirely?