Redigera

Dela via


ZipFile.ExtractToDirectoryAsync Method

Definition

Overloads

ExtractToDirectoryAsync(String, String, Boolean, CancellationToken)

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

ExtractToDirectoryAsync(Stream, String, CancellationToken)

Asynchronously extracts all the files from the zip archive stored in the specified stream and places them in the specified destination directory on the file system.

ExtractToDirectoryAsync(String, String, CancellationToken)

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

ExtractToDirectoryAsync(Stream, String, Boolean, CancellationToken)

Asynchronously extracts all the files from the zip archive stored in the specified stream and places them in the specified destination directory on the file system, and optionally allows choosing if the files in the destination directory should be overwritten.

ExtractToDirectoryAsync(Stream, String, Encoding, CancellationToken)

Asynchronously extracts all the files from the zip archive stored in the specified stream and places them in the specified destination directory on the file system and uses the specified character encoding for entry names.

ExtractToDirectoryAsync(String, String, Encoding, CancellationToken)

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

ExtractToDirectoryAsync(Stream, String, Encoding, Boolean, CancellationToken)

Asynchronously extracts all the files from the zip archive stored in the specified stream and places them in the specified destination directory on the file system, uses the specified character encoding for entry names, and optionally allows choosing if the files in the destination directory should be overwritten.

ExtractToDirectoryAsync(String, String, Encoding, Boolean, CancellationToken)

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

The specified directory must not exist. This method will create all subdirectories and the specified directory.

If there is an error while extracting the archive, the archive will remain partially extracted. Each entry will be extracted such that the extracted file has the same relative path to the destinationDirectoryName as the entry has to the archive. The path is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. 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.

ExtractToDirectoryAsync(String, String, Boolean, CancellationToken)

Source:
ZipFile.Extract.Async.cs

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

public static System.Threading.Tasks.Task ExtractToDirectoryAsync(string sourceArchiveFileName, string destinationDirectoryName, bool overwriteFiles, System.Threading.CancellationToken cancellationToken = default);
static member ExtractToDirectoryAsync : string * string * bool * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Shared Function ExtractToDirectoryAsync (sourceArchiveFileName As String, destinationDirectoryName As String, overwriteFiles As Boolean, Optional cancellationToken As CancellationToken = Nothing) As Task

Parameters

sourceArchiveFileName
String

The path to the archive on the file system that is to be extracted.

destinationDirectoryName
String

The path to the directory in which to place the extracted files, specified as a relative or absolute path. A relative path is interpreted as relative to the current working directory.

overwriteFiles
Boolean

true to overwrite files; false otherwise.

cancellationToken
CancellationToken

The cancellation token to monitor for cancellation requests.

Returns

Exceptions

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

sourceArchiveFileName or destinationDirectoryName is null.

sourceArchiveFileName or destinationDirectoryName specifies a path, file name, or both that exceeds 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 path specified by sourceArchiveFileName or destinationDirectoryName is invalid, (for example, it is on an unmapped drive).

An I/O error has occurred.

-or-

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 result in a file destination that is outside the destination directory (for example, because of 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.

sourceArchiveFileName or destinationDirectoryName is in an invalid format.

sourceArchiveFileName was not found.

sourceArchiveFileName not a valid ZipArchive.

-or-

An archive entry was not found or was corrupt.

-or-

An archive entry has been compressed using a compression method that isn't supported.

An asynchronous operation is cancelled.

Remarks

The specified directory must not exist. This method will create all subdirectories and the specified directory.

If there is an error while extracting the archive, the archive will remain partially extracted. Each entry will be extracted such that the extracted file has the same relative path to the destinationDirectoryName as the entry has to the archive. The path is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. 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(Stream, String, CancellationToken)

Source:
ZipFile.Extract.Async.cs

Asynchronously extracts all the files from the zip archive stored in the specified stream and places them in the specified destination directory on the file system.

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

Parameters

source
Stream

The stream from which the zip archive is to be extracted.

destinationDirectoryName
String

The path to the directory in which to place the extracted files, specified as a relative or absolute path. A relative path is interpreted as relative to the current working directory.

cancellationToken
CancellationToken

The cancellation token to monitor for cancellation requests.

Returns

Exceptions

destinationDirectoryName is Empty, contains only white space, or contains at least one invalid character.

destinationDirectoryName or source is null.

The specified path in destinationDirectoryName exceeds the system-defined maximum length.

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

The name of an entry in the archive is Empty, contains only white space, or contains at least one invalid character.

-or-

Extracting an archive entry would create a file that is outside the directory specified by destinationDirectoryName. (For example, this might happen if the entry name contains parent directory accessors.)

-or-

An archive entry to extract has the same name as an entry that has already been extracted or that exists in destinationDirectoryName.

The caller does not have the required permission to access the archive or the destination directory.

destinationDirectoryName contains an invalid format.

The archive contained in the source stream is not a valid zip archive.

-or-

An archive entry was not found or was corrupt.

-or-

An archive entry was compressed by using a compression method that isn't supported.

An asynchronous operation is cancelled.

Remarks

This method creates the specified directory and all subdirectories. The destination directory cannot already exist.

Exceptions related to validating the paths in the destinationDirectoryName or the files in the zip archive contained in source parameters are thrown before extraction. Otherwise, if an error occurs during extraction, the archive remains partially extracted.

Each extracted file has the same relative path to the directory specified by destinationDirectoryName as its source entry has to the root of the archive.

If a file to be archived has an invalid last modified time, the first date and time representable in the zip timestamp format (midnight on January 1, 1980) will be used.

Applies to

ExtractToDirectoryAsync(String, String, CancellationToken)

Source:
ZipFile.Extract.Async.cs

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

public static System.Threading.Tasks.Task ExtractToDirectoryAsync(string sourceArchiveFileName, string destinationDirectoryName, System.Threading.CancellationToken cancellationToken = default);
static member ExtractToDirectoryAsync : string * string * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Shared Function ExtractToDirectoryAsync (sourceArchiveFileName As String, destinationDirectoryName As String, Optional cancellationToken As CancellationToken = Nothing) As Task

Parameters

sourceArchiveFileName
String

The path to the archive on the file system that is to be extracted.

destinationDirectoryName
String

The path to the directory in which to place the extracted files, specified as a relative or absolute path. A relative path is interpreted as relative to the current working directory.

cancellationToken
CancellationToken

The cancellation token to monitor for cancellation requests.

Returns

Exceptions

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

sourceArchiveFileName or destinationDirectoryName is null.

sourceArchiveFileName or destinationDirectoryName specifies a path, file name, or both that exceeds 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 path specified by sourceArchiveFileName or destinationDirectoryName is invalid, (for example, it is on an unmapped drive).

An I/O error has occurred.

-or-

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 result in a file destination that is outside the destination directory (for example, because of 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.

sourceArchiveFileName or destinationDirectoryName is in an invalid format.

sourceArchiveFileName was not found.

The archive specified by sourceArchiveFileName is not a valid ZipArchive.

-or-

An archive entry was not found or was corrupt.

-or-

An archive entry has been compressed using a compression method that isn't supported.

An asynchronous operation is cancelled.

Remarks

The specified directory must not exist. This method will create all subdirectories and the specified directory.

If there is an error while extracting the archive, the archive will remain partially extracted. Each entry will be extracted such that the extracted file has the same relative path to the destinationDirectoryName as the entry has to the archive. The path is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. 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(Stream, String, Boolean, CancellationToken)

Source:
ZipFile.Extract.Async.cs

Asynchronously extracts all the files from the zip archive stored in the specified stream and places them in the specified destination directory on the file system, and optionally allows choosing if the files in the destination directory should be overwritten.

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

Parameters

source
Stream

The stream from which the zip archive is to be extracted.

destinationDirectoryName
String

The path to the directory in which to place the extracted files, specified as a relative or absolute path. A relative path is interpreted as relative to the current working directory.

overwriteFiles
Boolean

true to overwrite files; false otherwise.

cancellationToken
CancellationToken

The cancellation token to monitor for cancellation requests.

Returns

Exceptions

destinationDirectoryName is Empty, contains only white space, or contains at least one invalid character.

destinationDirectoryName or source is null.

The specified path in destinationDirectoryName exceeds the system-defined maximum length.

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

The name of an entry in the archive is Empty, contains only white space, or contains at least one invalid character.

-or-

Extracting an archive entry would create a file that is outside the directory specified by destinationDirectoryName. (For example, this might happen if the entry name contains parent directory accessors.)

-or-

overwriteFiles is false and an archive entry to extract has the same name as an entry that has already been extracted or that exists in destinationDirectoryName.

The caller does not have the required permission to access the archive or the destination directory.

destinationDirectoryName contains an invalid format.

The archive contained in the source stream is not a valid zip archive.

-or-

An archive entry was not found or was corrupt.

-or-

An archive entry was compressed by using a compression method that isn't supported.

An asynchronous operation is cancelled.

Remarks

This method creates the specified directory and all subdirectories. The destination directory cannot already exist.

Exceptions related to validating the paths in the destinationDirectoryName or the files in the zip archive contained in source parameters are thrown before extraction. Otherwise, if an error occurs during extraction, the archive remains partially extracted.

Each extracted file has the same relative path to the directory specified by destinationDirectoryName as its source entry has to the root of the archive.

If a file to be archived has an invalid last modified time, the first date and time representable in the zip timestamp format (midnight on January 1, 1980) will be used.

Applies to

ExtractToDirectoryAsync(Stream, String, Encoding, CancellationToken)

Source:
ZipFile.Extract.Async.cs

Asynchronously extracts all the files from the zip archive stored in the specified stream and places them in the specified destination directory on the file system and uses the specified character encoding for entry names.

public static System.Threading.Tasks.Task ExtractToDirectoryAsync(System.IO.Stream source, string destinationDirectoryName, System.Text.Encoding? entryNameEncoding, System.Threading.CancellationToken cancellationToken = default);
static member ExtractToDirectoryAsync : System.IO.Stream * string * System.Text.Encoding * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Shared Function ExtractToDirectoryAsync (source As Stream, destinationDirectoryName As String, entryNameEncoding As Encoding, Optional cancellationToken As CancellationToken = Nothing) As Task

Parameters

source
Stream

The stream from which the zip archive is to be extracted.

destinationDirectoryName
String

The path to the directory in which to place the extracted files, specified as a relative or absolute path. A relative path is interpreted as relative to the current working directory.

entryNameEncoding
Encoding

The encoding to use when reading or writing entry names and comments in this archive. Specify a value for this parameter only when an encoding is required for interoperability with zip archive tools and libraries that do not support UTF-8 encoding for entry names or comments.

cancellationToken
CancellationToken

The cancellation token to monitor for cancellation requests.

Returns

Exceptions

destinationDirectoryName is Empty, contains only white space, or contains at least one invalid character.

-or-

entryNameEncoding is set to a Unicode encoding other than UTF-8.

destinationDirectoryName or source is null.

The specified path in destinationDirectoryName exceeds the system-defined maximum length.

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

The name of an entry in the archive is Empty, contains only white space, or contains at least one invalid character.

-or-

Extracting an archive entry would create a file that is outside the directory specified by destinationDirectoryName. (For example, this might happen if the entry name contains parent directory accessors.)

-or-

An archive entry to extract has the same name as an entry that has already been extracted or that exists in destinationDirectoryName.

The caller does not have the required permission to access the archive or the destination directory.

destinationDirectoryName contains an invalid format.

The archive contained in the source stream is not a valid zip archive.

-or-

An archive entry was not found or was corrupt.

-or-

An archive entry was compressed by using a compression method that isn't supported.

An asynchronous operation is cancelled.

Remarks

This method creates the specified directory and all subdirectories. The destination directory cannot already exist.

Exceptions related to validating the paths in the destinationDirectoryName or the files in the zip archive contained in source parameters are thrown before extraction. Otherwise, if an error occurs during extraction, the archive remains partially extracted.

Each extracted file has the same relative path to the directory specified by destinationDirectoryName as its source entry has to the root of the archive.

If a file to be archived has an invalid last modified time, the first date and time representable in the zip timestamp format (midnight on January 1, 1980) will be used.

Applies to

ExtractToDirectoryAsync(String, String, Encoding, CancellationToken)

Source:
ZipFile.Extract.Async.cs

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

public static System.Threading.Tasks.Task ExtractToDirectoryAsync(string sourceArchiveFileName, string destinationDirectoryName, System.Text.Encoding? entryNameEncoding, System.Threading.CancellationToken cancellationToken = default);
static member ExtractToDirectoryAsync : string * string * System.Text.Encoding * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Shared Function ExtractToDirectoryAsync (sourceArchiveFileName As String, destinationDirectoryName As String, entryNameEncoding As Encoding, Optional cancellationToken As CancellationToken = Nothing) As Task

Parameters

sourceArchiveFileName
String

The path to the archive on the file system that is to be extracted.

destinationDirectoryName
String

The path to the directory on the file system. The directory specified must not exist, but the directory that it is contained in must exist.

entryNameEncoding
Encoding

The encoding to use when reading or writing entry names and comments in this ZipArchive.

cancellationToken
CancellationToken

The cancellation token to monitor for cancellation requests.

Returns

Exceptions

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

sourceArchiveFileName or destinationDirectoryName is null.

sourceArchiveFileName or destinationDirectoryName specifies a path, file name, or both that exceeds 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 path specified by sourceArchiveFileName or destinationDirectoryName is invalid, (for example, it is on an unmapped drive).

An I/O error has occurred.

-or-

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 result in a file destination that is outside the destination directory (for example, because of 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.

sourceArchiveFileName or destinationDirectoryName is in an invalid format.

sourceArchiveFileName was not found.

The archive specified by sourceArchiveFileName is not a valid ZipArchive.

-or-

An archive entry was not found or was corrupt.

-or-

An archive entry has been compressed using a compression method that isn't supported.

An asynchronous operation is cancelled.

Remarks

The specified directory must not exist. This method will create all subdirectories and the specified directory.

If there is an error while extracting the archive, the archive will remain partially extracted. Each entry will be extracted such that the extracted file has the same relative path to the destinationDirectoryName as the entry has to the archive. The path is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. 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.

Specifying a value other than null for entryNameEncoding is discouraged. However, this might be necessary for interoperability with zip archive tools and libraries that do not correctly support UTF-8 encoding for entry names or comments.

This value is used as follows:

  • If entryNameEncoding is not specified (== null):
    • For entries where the language encoding flag (EFS) in the general purpose bit flag of the local file header is not set, use the current system default code page (Encoding.Default) to decode the entry name and comment.
    • For entries where the language encoding flag (EFS) in the general purpose bit flag of the local file header is set, use UTF-8 (Encoding.UTF8) to decode the entry name and comment.
  • If entryNameEncoding is specified (!= null):
    • For entries where the language encoding flag (EFS) in the general purpose bit flag of the local file header is not set, use the specified entryNameEncoding to decode the entry name and comment.
    • For entries where the language encoding flag (EFS) in the general purpose bit flag of the local file header is set, use UTF-8 (Encoding.UTF8) to decode the entry name and comment.

Unicode encodings other than UTF-8 can't be used for the entryNameEncoding, otherwise an ArgumentException is thrown.

Applies to

ExtractToDirectoryAsync(Stream, String, Encoding, Boolean, CancellationToken)

Source:
ZipFile.Create.cs

Asynchronously extracts all the files from the zip archive stored in the specified stream and places them in the specified destination directory on the file system, uses the specified character encoding for entry names, and optionally allows choosing if the files in the destination directory should be overwritten.

public static System.Threading.Tasks.Task ExtractToDirectoryAsync(System.IO.Stream source, string destinationDirectoryName, System.Text.Encoding? entryNameEncoding, bool overwriteFiles, System.Threading.CancellationToken cancellationToken = default);
static member ExtractToDirectoryAsync : System.IO.Stream * string * System.Text.Encoding * bool * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Shared Function ExtractToDirectoryAsync (source As Stream, destinationDirectoryName As String, entryNameEncoding As Encoding, overwriteFiles As Boolean, Optional cancellationToken As CancellationToken = Nothing) As Task

Parameters

source
Stream

The stream from which the zip archive is to be extracted.

destinationDirectoryName
String

The path to the directory in which to place the extracted files, specified as a relative or absolute path. A relative path is interpreted as relative to the current working directory.

entryNameEncoding
Encoding

The encoding to use when reading or writing entry names and comments in this archive. Specify a value for this parameter only when an encoding is required for interoperability with zip archive tools and libraries that do not support UTF-8 encoding for entry names or comments.

overwriteFiles
Boolean

true to overwrite files; false otherwise.

cancellationToken
CancellationToken

The cancellation token to monitor for cancellation requests.

Returns

Exceptions

destinationDirectoryName is Empty, contains only white space, or contains at least one invalid character.

-or-

entryNameEncoding is set to a Unicode encoding other than UTF-8.

destinationDirectoryName or source is null.

The specified path in destinationDirectoryName exceeds the system-defined maximum length.

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

The name of an entry in the archive is Empty, contains only white space, or contains at least one invalid character.

-or-

Extracting an archive entry would create a file that is outside the directory specified by destinationDirectoryName. (For example, this might happen if the entry name contains parent directory accessors.)

-or-

overwriteFiles is false and an archive entry to extract has the same name as an entry that has already been extracted or that exists in destinationDirectoryName.

The caller does not have the required permission to access the archive or the destination directory.

destinationDirectoryName contains an invalid format.

The archive contained in the source stream is not a valid zip archive.

-or-

An archive entry was not found or was corrupt.

-or-

An archive entry was compressed by using a compression method that isn't supported.

An asynchronous operation is cancelled.

Remarks

This method creates the specified directory and all subdirectories. The destination directory cannot already exist.

Exceptions related to validating the paths in the destinationDirectoryName or the files in the zip archive contained in source parameters are thrown before extraction. Otherwise, if an error occurs during extraction, the archive remains partially extracted.

Each extracted file has the same relative path to the directory specified by destinationDirectoryName as its source entry has to the root of the archive.

If a file to be archived has an invalid last modified time, the first date and time representable in the zip timestamp format (midnight on January 1, 1980) will be used.

Applies to

ExtractToDirectoryAsync(String, String, Encoding, Boolean, CancellationToken)

Source:
ZipFile.Create.cs

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

The specified directory must not exist. This method will create all subdirectories and the specified directory.

If there is an error while extracting the archive, the archive will remain partially extracted. Each entry will be extracted such that the extracted file has the same relative path to the destinationDirectoryName as the entry has to the archive. The path is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. 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.

public static System.Threading.Tasks.Task ExtractToDirectoryAsync(string sourceArchiveFileName, string destinationDirectoryName, System.Text.Encoding? entryNameEncoding, bool overwriteFiles, System.Threading.CancellationToken cancellationToken = default);
static member ExtractToDirectoryAsync : string * string * System.Text.Encoding * bool * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Shared Function ExtractToDirectoryAsync (sourceArchiveFileName As String, destinationDirectoryName As String, entryNameEncoding As Encoding, overwriteFiles As Boolean, Optional cancellationToken As CancellationToken = Nothing) As Task

Parameters

sourceArchiveFileName
String

The path to the archive on the file system that is to be extracted.

destinationDirectoryName
String

The path to the directory in which to place the extracted files, specified as a relative or absolute path. A relative path is interpreted as relative to the current working directory.

entryNameEncoding
Encoding

The encoding to use when reading or writing entry names and comments in this ZipArchive.

overwriteFiles
Boolean

true to overwrite files; false otherwise.

cancellationToken
CancellationToken

The cancellation token to monitor for cancellation requests.

Returns

Exceptions

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

sourceArchiveFileName or destinationDirectoryName is null.

sourceArchiveFileName or destinationDirectoryName specifies a path, file name, or both that exceeds 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 path specified by sourceArchiveFileName or destinationDirectoryName is invalid, (for example, it is on an unmapped drive).

An I/O error has occurred.

-or-

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 result in a file destination that is outside the destination directory (for example, because of 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.

sourceArchiveFileName or destinationDirectoryName is in an invalid format.

sourceArchiveFileName was not found.

The archive specified by sourceArchiveFileName is not a valid ZipArchive.

-or-

An archive entry was not found or was corrupt.

-or-

An archive entry has been compressed using a compression method that isn't supported.

An asynchronous operation is cancelled.

Remarks

Specifying a value other than null for entryNameEncoding is discouraged. However, this might be necessary for interoperability with zip archive tools and libraries that do not correctly support UTF-8 encoding for entry names or comments.

This value is used as follows:

  • If entryNameEncoding is not specified (== null):
    • For entries where the language encoding flag (EFS) in the general purpose bit flag of the local file header is not set, use the current system default code page (Encoding.Default) to decode the entry name and comment.
    • For entries where the language encoding flag (EFS) in the general purpose bit flag of the local file header is set, use UTF-8 (Encoding.UTF8) to decode the entry name and comment.
  • If entryNameEncoding is specified (!= null):
    • For entries where the language encoding flag (EFS) in the general purpose bit flag of the local file header is not set, use the specified entryNameEncoding to decode the entry name and comment.
    • For entries where the language encoding flag (EFS) in the general purpose bit flag of the local file header is set, use UTF-8 (Encoding.UTF8) to decode the entry name and comment.

Unicode encodings other than UTF-8 can't be used for the entryNameEncoding, otherwise an ArgumentException is thrown.

Applies to