ZipFileExtensions.ExtractToFileAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
| ExtractToFileAsync(ZipArchiveEntry, String, CancellationToken) |
Asynchronously creates a file on the file system with the entry's contents and the specified name. |
| ExtractToFileAsync(ZipArchiveEntry, String, Boolean, CancellationToken) |
Asynchronously creates a file on the file system with the entry's contents and the specified name. |
ExtractToFileAsync(ZipArchiveEntry, String, CancellationToken)
Asynchronously creates a file on the file system with the entry's contents and the specified name.
public static System.Threading.Tasks.Task ExtractToFileAsync(this System.IO.Compression.ZipArchiveEntry source, string destinationFileName, System.Threading.CancellationToken cancellationToken = default);
static member ExtractToFileAsync : System.IO.Compression.ZipArchiveEntry * string * System.Threading.CancellationToken -> System.Threading.Tasks.Task
<Extension()>
Public Function ExtractToFileAsync (source As ZipArchiveEntry, destinationFileName As String, Optional cancellationToken As CancellationToken = Nothing) As Task
Parameters
- source
- ZipArchiveEntry
The zip archive entry to extract a file from.
- destinationFileName
- String
The name of the file that will hold the contents of the entry.
- cancellationToken
- CancellationToken
The cancellation token to monitor for cancellation requests.
Returns
Exceptions
The caller does not have the required permission.
destinationFileName is a zero-length string, contains only whitespace, or contains one or more invalid characters as defined by InvalidPathChars.
-or-
destinationFileName specifies a directory.
destinationFileName 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 path specified in destinationFileName is invalid (for example, it is on an unmapped drive).
An I/O error has occurred.
-or-
The entry is currently open for writing.
-or-
The entry has been deleted from the archive.
destinationFileName is in an invalid format.
-or-
The ZipArchive that this entry belongs to was opened in a write-only mode.
The entry is missing from the archive or is corrupt and cannot be read.
-or-
The entry has been compressed using a compression method that is not supported.
The ZipArchive that this entry belongs to has been disposed.
Remarks
The specified path is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory.
The last write time of the file is set to the entry's last write time. This method does not allow overwriting of an existing file with the same name. Attempting to extract explicit directories (entries with names that end in directory separator characters) will not result in the creation of a directory.
Applies to
ExtractToFileAsync(ZipArchiveEntry, String, Boolean, CancellationToken)
Asynchronously creates a file on the file system with the entry's contents and the specified name.
public static System.Threading.Tasks.Task ExtractToFileAsync(this System.IO.Compression.ZipArchiveEntry source, string destinationFileName, bool overwrite, System.Threading.CancellationToken cancellationToken = default);
static member ExtractToFileAsync : System.IO.Compression.ZipArchiveEntry * string * bool * System.Threading.CancellationToken -> System.Threading.Tasks.Task
<Extension()>
Public Function ExtractToFileAsync (source As ZipArchiveEntry, destinationFileName As String, overwrite As Boolean, Optional cancellationToken As CancellationToken = Nothing) As Task
Parameters
- source
- ZipArchiveEntry
The zip archive entry to extract a file from.
- destinationFileName
- String
The name of the file that will hold the contents of the entry.
- overwrite
- Boolean
true to overwrite files; false otherwise.
- cancellationToken
- CancellationToken
The cancellation token to monitor for cancellation requests.
Returns
Exceptions
The caller does not have the required permission.
destinationFileName is a zero-length string, contains only whitespace, or contains one or more invalid characters as defined by InvalidPathChars.
-or-
destinationFileName specifies a directory.
destinationFileName 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 path specified in destinationFileName is invalid (for example, it is on an unmapped drive).
An I/O error has occurred.
-or-
The entry is currently open for writing.
-or-
The entry has been deleted from the archive.
destinationFileName is in an invalid format.
-or-
The ZipArchive that this entry belongs to was opened in a write-only mode.
The entry is missing from the archive or is corrupt and cannot be read.
-or-
The entry has been compressed using a compression method that is not supported.
The ZipArchive that this entry belongs to has been disposed.
An asynchronous operation is cancelled.
Remarks
The specified path is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory.
The last write time of the file is set to the entry's last write time.
This method does allows overwriting of an existing file with the same name.