BinaryRage.Functions.Compress.DecompressGZip C# (CSharp) Method

DecompressGZip() public static method

public static DecompressGZip ( byte gzip ) : byte[]
gzip byte
return byte[]
        public static byte[] DecompressGZip(byte[] gzip)
        {
            if(gzip !=null)
            {
            using (GZipStream stream = new GZipStream(new MemoryStream(gzip), CompressionMode.Decompress))
            {
                const int size = 4096;
                byte[] buffer = new byte[size];
                using (MemoryStream memory = new MemoryStream())
                {
                    int count = 0;
                    do
                    {
                        count = stream.Read(buffer, 0, size);
                        if (count > 0)
                        {
                            memory.Write(buffer, 0, count);
                        }
                    }
                    while (count > 0);
                    return memory.ToArray();
                }
            }
            }

            return null;
        }