Edit

Share via


TarFile.ExtractToDirectoryAsync Method

Definition

Overloads

ExtractToDirectoryAsync(Stream, String, Boolean, CancellationToken)

Asynchronously extracts the contents of a stream that represents a tar archive into the specified directory.

ExtractToDirectoryAsync(String, String, Boolean, CancellationToken)

Asynchronously extracts the contents of a tar file into the specified directory.

ExtractToDirectoryAsync(Stream, String, Boolean, CancellationToken)

Source:
TarFile.cs
Source:
TarFile.cs
Source:
TarFile.cs

Asynchronously extracts the contents of a stream that represents a tar archive into the specified directory.

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 containing the tar archive.

destinationDirectoryName
String

The path of the destination directory where the filesystem entries should be extracted.

overwriteFiles
Boolean

true to overwrite files and directories in destinationDirectoryName; false to avoid overwriting, and throw if any files or directories are found with existing names.

cancellationToken
CancellationToken

The token to monitor for cancellation requests. The default value is None.

Returns

A task that represents the asynchronous extraction operation.

Exceptions

source or destinationDirectoryName is null.

The destinationDirectoryName directory path is not found.

Permissions are insufficient.

Extracting one of the tar entries would have resulted in a file outside the specified destination directory.

-or-

destinationDirectoryName is empty.

-or-

source does not support reading.

An I/O exception occurred.

The cancellation token was canceled. This exception is stored into the returned task.

Remarks

Files of type BlockDevice, CharacterDevice, or Fifo can only be extracted in Unix platforms.

Elevation is required to extract a BlockDevice or CharacterDevice to disk.

This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by ExtractToDirectory(Stream, String, Boolean).

Applies to

ExtractToDirectoryAsync(String, String, Boolean, CancellationToken)

Source:
TarFile.cs
Source:
TarFile.cs
Source:
TarFile.cs

Asynchronously extracts the contents of a tar file into the specified directory.

public static System.Threading.Tasks.Task ExtractToDirectoryAsync (string sourceFileName, 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 (sourceFileName As String, destinationDirectoryName As String, overwriteFiles As Boolean, Optional cancellationToken As CancellationToken = Nothing) As Task

Parameters

sourceFileName
String

The path of the tar file to extract.

destinationDirectoryName
String

The path of the destination directory where the filesystem entries should be extracted.

overwriteFiles
Boolean

true to overwrite files and directories in destinationDirectoryName; false to avoid overwriting, and throw if any files or directories are found with existing names.

cancellationToken
CancellationToken

The token to monitor for cancellation requests. The default value is None.

Returns

A task that represents the asynchronous extraction operation.

Exceptions

sourceFileName or destinationDirectoryName is null.

The destinationDirectoryName directory path is not found.

The sourceFileName file path is not found.

Permissions are insufficient.

Extracting one of the tar entries would have resulted in a file outside the specified destination directory.

-or-

sourceFileName or destinationDirectoryName is empty.

An I/O exception occurred.

The cancellation token was canceled. This exception is stored into the returned task.

Remarks

Files of type BlockDevice, CharacterDevice, or Fifo can only be extracted in Unix platforms.

Elevation is required to extract a BlockDevice or CharacterDevice to disk.

This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by ExtractToDirectory(String, String, Boolean).

Applies to