Have been currently trying to decompress a GZip-compressed string where I am using this function:
private static string Decompress(byte[] bytes)
{
using (var memoryStream = new MemoryStream(bytes))
using (var gZipStream = new GZipStream(memoryStream, CompressionMode.Decompress))
using (var memoryStreamOutput = new MemoryStream())
{
gZipStream.CopyTo(memoryStreamOutput);
var outputBytes = memoryStreamOutput.ToArray();
string decompressed = Encoding.UTF8.GetString(outputBytes);
return decompressed;
}
}
And whenever I run the code, the string I plugged in when calling the function is unchanged where it is supposed to be decompressed. I have also tried using StreamReader, which didn't work neither. What happened?