CSharp examples for System.IO.Compression:GZip
Decompress a byte[] with Gzip
using System.IO.Compression; using System.IO;//from w w w . ja va 2 s .com using System; public class Main{ /// <summary> /// Decompress a byte[]. /// </summary> /// <param name="gzBuffer"></param> /// <returns>byte array decompressed.</returns> public static byte[] Decompress(byte[] gzBuffer) { var ms = new MemoryStream(); var msgLength = BitConverter.ToInt32(gzBuffer, 0); ms.Write(gzBuffer, 4, gzBuffer.Length - 4); var buffer = new byte[msgLength]; ms.Position = 0; var zip = new GZipStream(ms, CompressionMode.Decompress); zip.Read(buffer, 0, buffer.Length); return buffer; } }