Freigeben über


IFileSystemProvider.CopyAsync Method

Definition

Copies a file or directory.

public:
 System::Threading::Tasks::Task ^ CopyAsync(Uri ^ sourceUri, Uri ^ destinationUri, bool overwrite, IProgress<Microsoft::VisualStudio::RpcContracts::FileSystem::OperationProgressData> ^ progress, System::Threading::CancellationToken cancellationToken);
public System.Threading.Tasks.Task CopyAsync (Uri sourceUri, Uri destinationUri, bool overwrite, IProgress<Microsoft.VisualStudio.RpcContracts.FileSystem.OperationProgressData>? progress, System.Threading.CancellationToken cancellationToken);
abstract member CopyAsync : Uri * Uri * bool * IProgress<Microsoft.VisualStudio.RpcContracts.FileSystem.OperationProgressData> * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Function CopyAsync (sourceUri As Uri, destinationUri As Uri, overwrite As Boolean, progress As IProgress(Of OperationProgressData), cancellationToken As CancellationToken) As Task

Parameters

sourceUri
Uri

The existing file or directory.

destinationUri
Uri

The new location.

overwrite
Boolean

True to overwrite existing files; otherwise false.

progress
IProgress<OperationProgressData>

The interface through which progress is reported.

cancellationToken
CancellationToken

The cancellation token.

Returns

A task representing the asynchronous copy operation.

Exceptions

sourceUri is null or destinationUri is null.

sourceUri does not exist.

The parent of destinationUri does not exist.

sourceUri refers to a file, destinationUri already exists and overwrite is false. ErrorCode will be set to FileAlreadyExists.

The caller does not have the required permission.

Remarks

If sourceUri refers to a directory and overwrite is true, destinationUri is removed before the copy is performed. If sourceUri refers to a directory and overwrite is false, the source directory is merged into the existing contents of the destination directory.

Applies to