Bewerken

Share via


TarFile.CreateFromDirectoryAsync Method

Definition

Overloads

CreateFromDirectoryAsync(String, Stream, Boolean, CancellationToken)

Asynchronously creates a tar stream that contains all the filesystem entries from the specified directory.

CreateFromDirectoryAsync(String, String, Boolean, CancellationToken)

Asynchronously creates a tar archive from the contents of the specified directory, and outputs them into the specified path. Can optionally include the base directory as the prefix for the entry names.

CreateFromDirectoryAsync(String, Stream, Boolean, CancellationToken)

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

Asynchronously creates a tar stream that contains all the filesystem entries from the specified directory.

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

Parameters

sourceDirectoryName
String

The path of the directory to archive.

destination
Stream

The destination stream of the archive.

includeBaseDirectory
Boolean

true to include the base directory name as the first path segment in all the names of the archive entries. false to exclude the base directory name from the entry name paths.

cancellationToken
CancellationToken

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

Returns

A task that represents the asynchronous creation operation.

Exceptions

sourceDirectoryName or destination is null.

sourceDirectoryName is empty.

-or-

destination does not support writing.

The sourceDirectoryName directory path is not found.

An I/O exception occurred.

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

Remarks

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 CreateFromDirectory(String, Stream, Boolean).

Applies to

CreateFromDirectoryAsync(String, String, Boolean, CancellationToken)

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

Asynchronously creates a tar archive from the contents of the specified directory, and outputs them into the specified path. Can optionally include the base directory as the prefix for the entry names.

public static System.Threading.Tasks.Task CreateFromDirectoryAsync (string sourceDirectoryName, string destinationFileName, bool includeBaseDirectory, System.Threading.CancellationToken cancellationToken = default);
static member CreateFromDirectoryAsync : string * string * bool * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Shared Function CreateFromDirectoryAsync (sourceDirectoryName As String, destinationFileName As String, includeBaseDirectory As Boolean, Optional cancellationToken As CancellationToken = Nothing) As Task

Parameters

sourceDirectoryName
String

The path of the directory to archive.

destinationFileName
String

The path of the destination archive file.

includeBaseDirectory
Boolean

true to include the base directory name as the first path segment in all the names of the archive entries. false to exclude the base directory name from the entry name paths.

cancellationToken
CancellationToken

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

Returns

A task that represents the asynchronous creation operation.

Exceptions

sourceDirectoryName or destinationFileName is null.

sourceDirectoryName or destinationFileName is empty.

The sourceDirectoryName directory path is not found.

An I/O exception occurred.

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

Remarks

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 CreateFromDirectory(String, String, Boolean).

Applies to