Note this code will not unzip general zip files. It only works with files zipped according to the package standard.
To unzip regular zip files, there are several components available.
I've used the Windows built-in COM component "Microsoft Shell Controls And Automation" (Add Reference, COM tab).
The code to unzip using this component is:
using Shell32;
static void Unzip(string zipFile, string directory) {
ShellClass sc = new ShellClass();
Folder source = sc.NameSpace(zipFile);
Folder target = sc.NameSpace(directory);
FolderItems items = source.Items();
const int options = (int)(CopyOptions.NoProgressDialog | CopyOptions.YesToAll);
target.CopyHere(items, options);
}
Where the
enum
values are:
[Flags]
internal enum CopyOptions {
NoProgressDialog = 4,
RenameDuplicates = 8,
YesToAll = 16,
PreserveUndo = 64,
AcceptWildcardOnly = 128,
ProgressDialogWithoutFilenames = 256,
CreateDirectoryWithoutDialog = 512,
NoDialogOnError = 1024,
NoRecursion = 4096,
OnlySpecifiedFiles = 8192
}
Cheers,
Michel
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.