Simple UnZIP
Demonstrates how to extract all files from a ZIP archive.
Usage
===================================================================== SimpleUnzip.exe ===================================================================== Extracts all files from a ZIP archive Syntax: SimpleUnzip.exe zip-file-path [target-directory] Example: SimpleUnzip.exe c:\archive.zip c:\temp
More info
The following code snippet is the core of the sample:
C#
// open a ZIP archive and extract files from it using (ZipArchive archive = new ZipArchive(@"c:\archive.zip", ArchiveOpenMode.Open)) { ArchiveOperationResult result = archive.ExtractAll( @"c:\temp", TransferMethod.Copy, ActionOnExistingFiles.OverwriteAll ); Console.WriteLine( "Extracted {0} file(s), {1} byte(s) from {2}.", result.FilesAffected, result.FilesUncompressedLength, archive.FilePath ); }
VB.NET
' open a ZIP archive and extract files from it Using archive As New ZipArchive("c:\archive.zip", ArchiveOpenMode.Open) Dim result As ArchiveOperationResult = archive.ExtractAll( _ "c:\temp", _ TransferMethod.Copy, _ ActionOnExistingFiles.OverwriteAll) Console.WriteLine( _ "Extracted {0} file(s), {1} byte(s) from {2}.", _ result.FilesAffected, _ result.FilesUncompressedLength, _ archive.FilePath) End Using