Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

c# gzip byte array

static byte[] Compress(byte[] data)
{
  using (var compressedStream = new MemoryStream())
  using (var zipStream = new GZipStream(compressedStream, CompressionMode.Compress))
  {
    zipStream.Write(data, 0, data.Length);
    zipStream.Close();
    return compressedStream.ToArray();
  }
}

static byte[] Decompress(byte[] data)
{
  using (var compressedStream = new MemoryStream(data))
  using (var zipStream = new GZipStream(compressedStream, CompressionMode.Decompress))
  using (var resultStream = new MemoryStream())
  {
    zipStream.CopyTo(resultStream);
    return resultStream.ToArray();
  }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #gzip #byte #array
ADD COMMENT
Topic
Name
1+9 =