IFileSystemProvider.CopyAsync Method

Definition

Copies a file or directory.

C++
public:
 System::Threading::Tasks::Task ^ CopyAsync(Uri ^ sourceUri, Uri ^ destinationUri, bool overwrite, IProgress<Microsoft::VisualStudio::RpcContracts::FileSystem::OperationProgressData> ^ progress, System::Threading::CancellationToken cancellationToken);

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

Produkt Versioner
Visual Studio SDK 2019, 2022