What makes it better than the gratis alternatives.
DotNetZip is one of those gratis alternatives for handling ZIP files.
It's a 100% managed code library to read, create, and update zip files
from within any .NET application.
It does zip passwords, zip passwords with AES encryption, ZIP64,
Unicode, self-extracting archives, and more. There's a good help file
with lots of examples (online version here:http://
cheeso.members.winisp.net/DotNetZipHelp/ ). There's also a support
forum on codeplex.
Here's some sample code to extract all files from a zip to a
particular directory, without overwriting existing files:
String TargetDirectory= "c:\\unpack";
using(Ionic.Zip.ZipFile zip= Ionic.Zip.ZipFile.Read
(ZipFileToExtract))
{
zip.ExtractAll(TargetDirectory,
Ionic.Zip.ExtractExistingFileAction.DontOverwrite);
}
Sample to extract entries conditionally, and overwrite any existing
files:
using (var zip1 = Ionic.Zip.ZipFile.Read(zipToUnpack))
{
foreach (var entry in zip1)
{
// extract only the entries I want:
if (wantExtract(entry.FileName))
entry.Extract(dir,
Ionic.Zip.ExtractExistingFileAction.OverwriteSilently);
}
}
Sample code to create a zip file, zipping up a directory:
using (var zip = new Ionic.Zip.ZipFile())
{
zip.AddDirectory(directory, System.IO.Path.GetFileName
(directory));
zip.Save(targetZip);
}
Sample to create a self-extracting archive (SFX):
using (var zip = new Ionic.Zip.ZipFile())
{
zip.AddDirectory(directory, System.IO.Path.GetFileName
(directory));
zip.Comment = "This will be embedded into a self-extracting
console-based exe";
zip.SaveSelfExtractor("archive.exe",
SelfExtractorFlavor.ConsoleApplication);
}
DotNetZip can also produce a Windows GUIs for the SFX.
check it out.
http://dotnetzip.codeplex.com.
(DotNetZip is free.)