Click or drag to resize

IHierarchyItemCopyToAsync Method

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: 6.0.4052-Beta
Syntax
Task CopyToAsync(
	IFolder destinationFolder,
	string destinationName,
	bool deep,
	bool overwrite,
	LockUriTokenPair[] lockTokens = null,
	IDictionary<string, string> headers = null,
	CancellationToken cancellationToken = null
)

Parameters

destinationFolder
Type: ITHit.WebDAV.ClientIFolder
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.
lockTokens (Optional)
Type: ITHit.WebDAV.ClientLockUriTokenPair
Lock tokens for destination folder or items to be overwritten if overwrite is true.
headers (Optional)
Type: System.Collections.GenericIDictionaryString, String
Request headers.
cancellationToken (Optional)
Type: System.ThreadingCancellationToken
Propagates notification that operations should be canceled.

Return Value

Type: Task

[Missing <returns> documentation for "M:ITHit.WebDAV.Client.IHierarchyItem.CopyToAsync(ITHit.WebDAV.Client.IFolder,System.String,System.Boolean,System.Boolean,ITHit.WebDAV.Client.LockUriTokenPair[],System.Collections.Generic.IDictionary{System.String,System.String},System.Threading.CancellationToken)"]

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...
WebDavSession session = new WebDavSession(license);
session.Credentials = new NetworkCredential("User1", "pwd");
IHierarchyItem file1 = await session.GetFileAsync(new Uri("https://server:8080/Library/image007.gif"));
LockInfo lockInfo1 = await file1.LockAsync(LockScope.Exclusive, false, "User 1", new TimeSpan(0, 5, 0));
IHierarchyItem file2 = await session.GetFileAsync(new Uri("https://server:8080/Library/image004.gif"));
LockInfo lockInfo2 = await file2.LockAsync(LockScope.Exclusive, false, "User 1", new TimeSpan(0, 5, 0));

LockUriTokenPair[] locks = new LockUriTokenPair[2];
locks[0] = lockInfo1.LockToken;
locks[1] = lockInfo2.LockToken;

IFolder itemSrc = await session.GetFolderAsync(new Uri("https://server:8080/Sales/Library/"));
IFolder itemDst = await session.GetFolderAsync(new Uri("https://server:8080/Library/"));

try
{
   await itemSrc.CopyToAsync(itemDst, itemSrc.DisplayName, true, true, locks);
}
catch (WebDavHttpException ex)
{
    Console.WriteLine(ex.Message + " " + ex.Status.Code + " " + ex.Status.Description);
    foreach (IMultistatusResponse resp in ex.Multistatus.Responses)
    { // Find which items failed to copy.
        Console.WriteLine(resp.Href + " " + resp.Status.Code + " " + resp.Status.Description);
    }
}
See Also