Xceed .NET Libraries Documentation
Xceed.Zip Assembly / Xceed.Zip Namespace / QuickZip Class / Unzip Method / Unzip(String,String,String,Boolean,Boolean,Boolean,DiskRequiredCallback,ByteProgressionCallback,ItemProgressionCallback,Object,String[]) Method
The fully-qualified path and name of the zip file.
The destination folder to where the files will be extracted.
The password that will be used to decrypt the files.
Boolean value indicating if existing files should be overwritten.
Boolean value indicating if files contained within sub-folders should be extracted from the zip file.
Boolean value indicating if the directory structure should be preserved in the destination folder.
The callback method called whenever the DiskRequired event is triggered.
Delegate for ByteProgression notification.
Delegate for ItemProgression notification.
Opaque data that will be passed back to the event handler when an event is raised.
The files to extract from zipFileName. Cannot be a null reference (Nothing in Visual Basic).


In This Topic
    Unzip(String,String,String,Boolean,Boolean,Boolean,DiskRequiredCallback,ByteProgressionCallback,ItemProgressionCallback,Object,String[]) Method
    In This Topic
    Extracts files from a zip file overwriting existing files and restoring the directory structure, using the provided decryption password, and tracking item or byte progression.
    Syntax
    'Declaration
     
    Public Overloads Shared Sub Unzip( _
       ByVal zipFileName As String, _
       ByVal destinationFolder As String, _
       ByVal decryptionPassword As String, _
       ByVal replaceExistingFiles As Boolean, _
       ByVal recursive As Boolean, _
       ByVal preservePaths As Boolean, _
       ByVal diskRequiredCallback As QuickZip.DiskRequiredCallback, _
       ByVal byteProgressionCallback As QuickZip.ByteProgressionCallback, _
       ByVal itemProgressionCallback As QuickZip.ItemProgressionCallback, _
       ByVal userParams As Object, _
       ByVal ParamArray filesToUnzip() As String _
    ) 
    'Usage
     
    Dim zipFileName As String
    Dim destinationFolder As String
    Dim decryptionPassword As String
    Dim replaceExistingFiles As Boolean
    Dim recursive As Boolean
    Dim preservePaths As Boolean
    Dim diskRequiredCallback As QuickZip.DiskRequiredCallback
    Dim byteProgressionCallback As QuickZip.ByteProgressionCallback
    Dim itemProgressionCallback As QuickZip.ItemProgressionCallback
    Dim userParams As Object
    Dim filesToUnzip() As String
     
    QuickZip.Unzip(zipFileName, destinationFolder, decryptionPassword, replaceExistingFiles, recursive, preservePaths, diskRequiredCallback, byteProgressionCallback, itemProgressionCallback, userParams, filesToUnzip)

    Parameters

    zipFileName
    The fully-qualified path and name of the zip file.
    destinationFolder
    The destination folder to where the files will be extracted.
    decryptionPassword
    The password that will be used to decrypt the files.
    replaceExistingFiles
    Boolean value indicating if existing files should be overwritten.
    recursive
    Boolean value indicating if files contained within sub-folders should be extracted from the zip file.
    preservePaths
    Boolean value indicating if the directory structure should be preserved in the destination folder.
    diskRequiredCallback
    The callback method called whenever the DiskRequired event is triggered.
    byteProgressionCallback
    Delegate for ByteProgression notification.
    itemProgressionCallback
    Delegate for ItemProgression notification.
    userParams
    Opaque data that will be passed back to the event handler when an event is raised.
    filesToUnzip
    The files to extract from zipFileName. Cannot be a null reference (Nothing in Visual Basic).
    Remarks

    Note that existing files will be overwritten, files contained within sub-folders will be extracted and the directory structure will be restored in the destination folder.

    Zip files are case sensitive therefore the string passed in the filesToUnzip parameter, will be used "as-is".

    For example, if a zip file contains a file named "FILE.TXT" and "file.txt" is passed to the filesToUnzip parameter, "FILE.TXT" will not be extracted.

    If the destination item(s) exists, the attributes and dates of the original item(s) are not applied to the destination item(s).

    Handling paths

    When extracting files from within a zip file, the directory structure can be restored fully or partially or it can be omitted altogether.

    If the preservePaths parameter of the Unzip method is set to false, the files specified in the filesToUnzip parameter will be restored directly into the root of the destination folder without recreating the directory structure.

    For example, if you have a zip file containing files in the "folder1" subfolder and files in the "folder1\folder2" subfolder, the following code will unzip all files right into "c:\temp", without creating any subfolders:

    C# Copy Code
    Xceed.Zip.QuickZip.Unzip( @"c:\test.zip", @"c:\temp", true, true, false, @"folder1\*" );

    If the preservePaths parameter is set to true, the part of the path that is explicitly included in the filesToUnzip parameter will not be restored into the destination folder.

    For example, for the same zip file as above, the following code will create the folder "folder2" into the "c:\temp" destination folder. Files that were in the "folder1" subfolder in the zip will be unzipped directly into the root of "c:\temp", and files that were in "folder1\folder2" will be unzipped into "c:\temp\folder2":

    C# Copy Code
    Xceed.Zip.QuickZip.Unzip( @"c:\test.zip", @"c:\temp", true, true, true, @"folder1\*" );

    The following example will unzip files into "c:\temp\folder1" and "c:\temp\folder1\folder2":

    C# Copy Code
    Xceed.Zip.QuickZip.Unzip( @"c:\test.zip", @"c:\temp", true, true, true, @"*" );

    Requirements

    Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also