Xceed .NET Libraries Documentation
Unzip(String,String,String[]) Method


Xceed.Zip Assembly > Xceed.Zip Namespace > QuickZip Class > Unzip Method : Unzip(String,String,String[]) Method
The fully-qualified path and name of the zip file.
The destination folder to where the files will be extracted.
The files to extract from zipFileName. Cannot be a null reference (Nothing in Visual Basic).
Extracts files from a zip file overwriting existing files and restoring the directory structure.
Syntax
'Declaration
 
Public Overloads Shared Sub Unzip( _

   ByVal zipFileName As String, _

   ByVal destinationFolder As String, _

   ByVal ParamArray filesToUnzip() As String _

) 
'Usage
 
Dim zipFileName As String

Dim destinationFolder As String

Dim filesToUnzip() As String

 

QuickZip.Unzip(zipFileName, destinationFolder, filesToUnzip)
public static void Unzip( 

   string zipFileName,

   string destinationFolder,

   params string[] filesToUnzip

)

Parameters

zipFileName
The fully-qualified path and name of the zip file.
destinationFolder
The destination folder to where the files will be extracted.
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

Reference

QuickZip Class
QuickZip Members
Overload List