.Net supports two compression formats: GZip and Deflate. I tried it and there was no difference in compression ratio or speed. Among them, GZip can be opened by WinRAR.
It is very simple to use, the following program compresses a string into a file:
using (DeflateStream gzip = new DeflateStream(fs, CompressionMode.Compress))
{
byte[] buf = Encoding.UTF8.GetBytes(this.txbSource.Text);
gzip.Write(buf, 0, buf.Length);
gzip.Flush();
}
Decompression only requires this:
gzip = new GZipStream(new MemoryStream(buf), CompressionMode.Decompress);
using (StreamReader reader = new StreamReader(gzip))
{
this.txbTarget.Text = reader.ReadToEnd();
}
If you are decompressing from a file, just change the MemoryStream to a FileStream.
Of course, you need to add: using System.IO.Compression;
http://www.cnblogs.com/fujingqiu/archive/2006/10/29/543347.html