GZipStream Compress - CSharp System.IO.Compression

CSharp examples for System.IO.Compression:GZip

Description

GZipStream Compress

Demo Code


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();
        }
}

Related Tutorials