CSharp examples for System.IO.Compression:GZip
GZipStream Compress
using System.Threading.Tasks; using System.Text; using System.Runtime.Serialization.Formatters.Binary; using System.Linq; using System.IO.Compression; using System.IO;//from w ww. java 2 s .com using System.Collections.Generic; using System; public class Main{ public static byte[] Compress(byte[] data) { MemoryStream ms = new MemoryStream(); GZipStream zipStream = new GZipStream(ms, CompressionMode.Compress); zipStream.Write(data, 0, data.Length); zipStream.Close(); return ms.ToArray(); } }