Click or drag to resize

IHierarchyItemAsyncCopyToAsync Method (IFolderAsync, String, Boolean, Boolean)

IT Hit WebDAV Classes Reference
Copies this item to destination folder.

Namespace:  ITHit.WebDAV.Client
Assembly:  ITHit.WebDAV.Client (in ITHit.WebDAV.Client.dll) Version: 2.0.420.0
Syntax
Task CopyToAsync(
	IFolderAsync destinationFolder,
	string destinationName,
	bool deep,
	bool overwrite
)

Parameters

destinationFolder
Type: ITHit.WebDAV.ClientIFolderAsync
Folder to copy to.
destinationName
Type: SystemString
Name to assign to copied item.
deep
Type: SystemBoolean
Indicates whether children of this item should be copied.
overwrite
Type: SystemBoolean
Whether existing destination item shall be overwritten.

Return Value

Type: Task

[Missing <returns> documentation for "M:ITHit.WebDAV.Client.IHierarchyItemAsync.CopyToAsync(ITHit.WebDAV.Client.IFolderAsync,System.String,System.Boolean,System.Boolean)"]

Exceptions
ExceptionCondition
ForbiddenException The source and destination URIs are the same.
LockedException The destination folder or items to be overwritten were locked.
PreconditionFailedException The destination item exists and overwrite was false.
NotFoundExceptionThis item doesn't exist on the server.
WebDavHttpExceptionServer returned unknown error for specific resource.
WebDavExceptionUnexpected error occurred.
Examples
string license = "<?xml version='1.0' encoding='utf...
WebDavSessionAsync session = new WebDavSessionAsync(license);
session.Credentials = new NetworkCredential("User1", "pwd");
IFolderAsync srcFolder = await session.OpenFolderAsync(new Uri("http://server:8080/Library/Sales"));
IFolderAsync dstFolder = await session.OpenFolderAsync(new Uri("http://server:8080/Library/"));

try
{
    await srcFolder.CopyToAsync(dstFolder, "Test1", true, false);
}
catch (PreconditionFailedException)
{
    Console.WriteLine("The destination item exists and 'overwrite' was 'false'.");
}
catch (WebDavHttpException ex)
{
    Console.WriteLine(ex.Message + " " + ex.Status.Code + " " + ex.Status.Description);
    foreach (IMultistatusResponseAsync resp in ex.Multistatus.Responses)
    { // Find which items failed to move.
        Console.WriteLine(resp.Href + " " + resp.Status.Code + " " + resp.Status.Description);
    }
}
See Also