ExtractAll Method (path)

DotNetZip

Ionic Zip Library v1.9.1.6 ExtractAll Method (path)
ReferenceIonic.ZipZipFileExtractAll(String)
Extracts all of the items in the zip archive, to the specified path in the filesystem. The path can be relative or fully-qualified.
Declaration Syntax
C# Visual Basic Visual C++
public void ExtractAll(
	string path
)
Public Sub ExtractAll ( _
	path As String _
)
public:
void ExtractAll(
	String^ path
)
Parameters
path (String)
The path to which the contents of the zipfile will be extracted. The path can be relative or fully-qualified.
Remarks

This method will extract all entries in the ZipFile to the specified path.

If an extraction of a file from the zip archive would overwrite an existing file in the filesystem, the action taken is dictated by the ExtractExistingFile property, which overrides any setting you may have made on individual ZipEntry instances. By default, if you have not set that property on the ZipFile instance, the entry will not be extracted, the existing file will not be overwritten and an exception will be thrown. To change this, set the property, or use the ExtractAll(String, ExtractExistingFileAction) overload that allows you to specify an ExtractExistingFileAction parameter.

The action to take when an extract would overwrite an existing file applies to all entries. If you want to set this on a per-entry basis, then you must use one of the ZipEntry.Extract methods.

This method will send verbose output messages to the StatusMessageTextWriter, if it is set on the ZipFile instance.

You may wish to take advantage of the ExtractProgress event.

About timestamps: When extracting a file entry from a zip archive, the extracted file gets the last modified time of the entry as stored in the archive. The archive may also store extended file timestamp information, including last accessed and created times. If these are present in the ZipEntry, then the extracted file will also get these times.

A Directory entry is somewhat different. It will get the times as described for a file entry, but, if there are file entries in the zip archive that, when extracted, appear in the just-created directory, then when those file entries are extracted, the last modified and last accessed times of the directory will change, as a side effect. The result is that after an extraction of a directory and a number of files within the directory, the last modified and last accessed timestamps on the directory will reflect the time that the last file was extracted into the directory, rather than the time stored in the zip archive for the directory.

To compensate, when extracting an archive with ExtractAll, DotNetZip will extract all the file and directory entries as described above, but it will then make a second pass on the directories, and reset the times on the directories to reflect what is stored in the zip archive.

This compensation is performed only within the context of an ExtractAll. If you call ZipEntry.Extract on a directory entry, the timestamps on directory in the filesystem will reflect the times stored in the zip. If you then call ZipEntry.Extract on a file entry, which is extracted into the directory, the timestamps on the directory will be updated to the current time.

Examples
This example extracts all the entries in a zip archive file, to the specified target directory. The extraction will overwrite any existing files silently.
CopyC#
String TargetDirectory= "unpack";
using(ZipFile zip= ZipFile.Read(ZipFileToExtract))
{
    zip.ExtractExistingFile= ExtractExistingFileAction.OverwriteSilently;
    zip.ExtractAll(TargetDirectory);
}
CopyVB.NET
Dim TargetDirectory As String = "unpack"
Using zip As ZipFile = ZipFile.Read(ZipFileToExtract)
    zip.ExtractExistingFile= ExtractExistingFileAction.OverwriteSilently
    zip.ExtractAll(TargetDirectory)
End Using

Assembly: Ionic.Zip (Module: Ionic.Zip) Version: 1.9.1.8 (1.9.1.8)