public byte[] Decompress(Stream inputStream) { using (var zlibStream = new ZlibStream(inputStream, CompressionMode.Decompress)) using (var outputStream = new MemoryStream()) { zlibStream.WriteTo(outputStream); return(outputStream.ToArray()); } }
public static byte[] Compress(byte[] data) { using (var inputStream = new MemoryStream(data)) using (var compressionStream = new ZlibStream(inputStream, CompressionMode.Compress)) using (var outputStream = new MemoryStream()) { compressionStream.WriteTo(outputStream); return(outputStream.ToArray()); } }