Edit

Share via


ZipFileExtensions.ExtractToDirectoryAsync Method

Definition

Overloads

ExtractToDirectoryAsync(ZipArchive, String, CancellationToken)

Asynchronously extracts all of the files in the archive to a directory on the file system. The specified directory can already exist.

ExtractToDirectoryAsync(ZipArchive, String, Boolean, CancellationToken)

Extracts all of the files in the archive to a directory on the file system. The specified directory may already exist.

ExtractToDirectoryAsync(ZipArchive, String, CancellationToken)

Source:
ZipFileExtensions.ZipArchive.Extract.Async.cs

Asynchronously extracts all of the files in the archive to a directory on the file system. The specified directory can already exist.

public static System.Threading.Tasks.Task ExtractToDirectoryAsync(this System.IO.Compression.ZipArchive source, string destinationDirectoryName, System.Threading.CancellationToken cancellationToken = default);
static member ExtractToDirectoryAsync : System.IO.Compression.ZipArchive * string * System.Threading.CancellationToken -> System.Threading.Tasks.Task
<Extension()>
Public Function ExtractToDirectoryAsync (source As ZipArchive, destinationDirectoryName As String, Optional cancellationToken As CancellationToken = Nothing) As Task

Parameters

source
ZipArchive

The zip archive to extract files from.

destinationDirectoryName
String

The path to the directory on the file system.

cancellationToken
CancellationToken

The cancellation token to monitor for cancellation requests.

Returns

Exceptions

destinationDirectoryName is a zero-length string, contains only whitespace, or contains one or more invalid characters as defined by InvalidPathChars.

destinationDirectoryName is null.

The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.

The specified path is invalid, (for example, it is on an unmapped drive).

An archive entry's name is zero-length, contains only whitespace, or contains one or more invalid characters as defined by InvalidPathChars.

-or-

Extracting an archive entry would have resulted in a destination file that is outside destinationDirectoryName (for example, if the entry name contains parent directory accessors).

-or-

An archive entry has the same name as an already extracted entry from the same archive.

The caller does not have the required permission.

destinationDirectoryName is in an invalid format.

An archive entry was not found or is corrupt.

-or-

An archive entry has been compressed using a compression method that is not supported.

An asynchronous operation is cancelled.

Remarks

The directory specified must not exist. The path is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory.

This method creates all subdirectories and the specified directory if necessary.

If there is an error while extracting the archive, the archive remains partially extracted.

Each entry is extracted such that the extracted file has the same relative path to destinationDirectoryName as the entry has to the root of the archive. If a file to be archived has an invalid last modified time, the first datetime representable in the Zip timestamp format (midnight on January 1, 1980) will be used.

Applies to

ExtractToDirectoryAsync(ZipArchive, String, Boolean, CancellationToken)

Source:
ZipFileExtensions.ZipArchive.Create.cs

Extracts all of the files in the archive to a directory on the file system. The specified directory may already exist.

public static System.Threading.Tasks.Task ExtractToDirectoryAsync(this System.IO.Compression.ZipArchive source, string destinationDirectoryName, bool overwriteFiles, System.Threading.CancellationToken cancellationToken = default);
static member ExtractToDirectoryAsync : System.IO.Compression.ZipArchive * string * bool * System.Threading.CancellationToken -> System.Threading.Tasks.Task
<Extension()>
Public Function ExtractToDirectoryAsync (source As ZipArchive, destinationDirectoryName As String, overwriteFiles As Boolean, Optional cancellationToken As CancellationToken = Nothing) As Task

Parameters

source
ZipArchive

The zip archive to extract files from.

destinationDirectoryName
String

The path to the directory on the file system.

overwriteFiles
Boolean

true to overwrite files; false otherwise.

cancellationToken
CancellationToken

The cancellation token to monitor for cancellation requests.

Returns

Exceptions

destinationDirectoryName is a zero-length string, contains only whitespace, or contains one or more invalid characters as defined by InvalidPathChars.

This method will create all subdirectories and the specified directory if necessary.

If there is an error while extracting the archive, the archive will remain partially extracted.

Each entry is extracted such that the extracted file has the same relative path to destinationDirectoryName as the entry has to the root of the archive. If a file to be archived has an invalid last modified time, the first datetime representable in the Zip timestamp format (midnight on January 1, 1980) will be used.

destinationDirectoryName is null.

The specified path, file name, or both exceed the system-defined maximum length.

For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.

The specified path is invalid, (for example, it is on an unmapped drive).

An archive entry's name is zero-length, contains only whitespace, or contains one or more invalid characters as defined by InvalidPathChars.

-or-

Extracting an archive entry would have resulted in a destination file that is outside destinationDirectoryName (for example, if the entry name contains parent directory accessors).

-or-

An archive entry has the same name as an already extracted entry from the same archive.

The caller does not have the required permission.

destinationDirectoryName is in an invalid format.

An archive entry was not found or was corrupt.

-or-

An archive entry has been compressed using a compression method that is not supported.

Remarks

The directory specified must not exist. The path is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory.

Applies to