Newsflash: The brand new Compact Framework 3.5 Beta1 now contains Compression!

Introduction


The Compact Framework is missing a crucial namespace for mobile device development - System.IO.Compression. In here lies the ability to compress text, xml, files or any Stream using popular ZIP compression. You can use it to save storage space on the device by compressing data used by your application. Or you can use it to compress information before transmitting it to a server to save GPRS costs and speed up transfer times. Simply use this library in the exact same way you would on the full framework.

Download Links


Free Download For CF1 downloads
Free Download For CF2 downloads

Example downloading a data set as compressed xml:


MyTypedDataSet dataSet = new MyTypedDataSet();
HttpWebResponse resp = (HttpWebResponse)syncRequest.EndGetResponse(res);
Stream ss = resp.GetResponseStream();
DeflateStream inf = new DeflateStream(ss, CompressionMode.Decompress);
dataSet.ReadXml(inf);
resp.Close();

Help Resources


For a more complete example of usage see this post on the Microsoft .NET Base Class Team's Blog.

Also, this MSDN article provides a good introduction by explaining the difference between DeflateStream and GZipStream.