Xceed Real-Time Zip for .NET Documentation
Unzip(String,String,Boolean,Boolean,Boolean,String[]) Method


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

   ByVal zipFileName As String, _

   ByVal destinationFolder As String, _

   ByVal replaceExistingFiles As Boolean, _

   ByVal recursive As Boolean, _

   ByVal preservePaths As Boolean, _

   ByVal ParamArray filesToUnzip() As String _

) 
'Usage
 
Dim zipFileName As String

Dim destinationFolder As String

Dim replaceExistingFiles As Boolean

Dim recursive As Boolean

Dim preservePaths As Boolean

Dim filesToUnzip() As String

 

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

   string zipFileName,

   string destinationFolder,

   bool replaceExistingFiles,

   bool recursive,

   bool preservePaths,

   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.
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.
filesToUnzip
The files to extract from zipFileName. Cannot be a null reference (Nothing in Visual Basic).
Remarks

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