Zippen unter .NET ist gar nicht so einfach. Zwar gibt es unterschiedliche 3rd-Party-Libraries, die eingebunden werden können, aber dann hat es sich auch schon wieder. Das .NET Framework bietet zwar den DeflateStream an, aber auch das ist nicht so wirklich das Wahre, da man damit doch sehr eingeschränkt ist.
Microsoft hat dies erkannt und die Library DotNetZip auf CodePlex zur Verfügung gestellt, die hier eine wesentliche Verbesserung bringt.
Hier ein Auszug aus der Beschreibung:
DotNetZip works on PCs with the full .NET Framework, and also runs on mobile devices that use the .NET Compact Framework. Create and read zip files in VB, C#, or any .NET language, or any scripting environment. DotNetZip supports these scenarios:
- an ASP.NET app that dynamically creates ZIP files and allows a browser to download them
- a Windows Service that periodically zips up a directory for backup and archival purposes
- a WPF program that modifyies an existing archive – renaming entries, removing entries from an archive, or adding new entries to an archive
- a Windows Forms app that creates AES-encrypted zip archives for privacy of archived content.
- An administrative script in PowerShell or VBScript that performs backup and archival.
- a WCF service that receives a zip file as an attachment, and dynamically unpacks the zip to a stream for analysis
- creating zip files from stream content, saving to a stream, extracting to a stream, reading from a stream
- creation of self-extracting archives.
Ein Blick auf diese Library lohnt sich auf jeden Fall für diejenigen, die mit ZIPs zu tun haben.
Ebenfalls wichtig: Die Library ist kostenlos.