... all I'm offering is the truth. Nothing more. RSS 2.0
# Wednesday, December 09, 2009

On a recent project I was asked to provide a real easy way to zip multiple files and while I have seen this problem solved many moons ago in VB6 I have never really thought about this question from a managed framework standpoint. While navigating MSDN I came across GZipStream but this did not explicitly provide an interface for adding files to a zip archive. Several Bings later I came across a highly rated project on CodePlex called DotNetZip.

I must say this got straight to the point, with a intuitive API that was well documented and explained. Here is a code sample:

using (ZipFile zip = newZipFile()
{
    // add this map file into the "images" directory in the zip archive
   
zip.AddFile("c:\\images\\personal\\7440-N49th.png", "images");
    // add the report into a different directory in the archive
   
zip.AddFile("c:\\Reports\\2008-Regional-Sales-Report.pdf", "files");
    zip.AddFile("ReadMe.txt");
   zip.Save("MyZipFile.zip");
}

DotNetZip is packaged as a single DLL, a single assembly. It is fully managed code, written in C#, and provides support for reading and writing Zip archive files and streams. The main type is ZipFile, featuring methods like Add(), Extract() and Save(). There are string and int indexers for the entries of the ZipFile. There are properties for things like password protection, unicode and codepage support, and ZIP64 behavior. And there are progress events for Reading, Saving, and Extracting.

Technorati Tags:
Wednesday, December 09, 2009 9:53:09 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] - Trackback
C#
Comments are closed.
Blogroll
Statistics
Total Posts: 330
This Year: 18
This Month: 2
This Week: 0
Comments: 30
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2010
Mark Downie
Sign In
All Content © 2010, Mark Downie
DasBlog theme 'Business' created by Christoph De Baene (delarou)