Click or drag to resize

IHierarchyItemAsyncCopyToAsync Method (IFolderAsync, String, Boolean, Boolean, LockUriTokenPair)

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
Task CopyToAsync(
	IFolderAsync destinationFolder,
	string destinationName,
	bool deep,
	bool overwrite,
	LockUriTokenPair[] lockTokens


Type: ITHit.WebDAV.ClientIFolderAsync
Folder to copy to.
Type: SystemString
Name to assign to copied item.
Type: SystemBoolean
Indicates whether children of this item should be copied.
Type: SystemBoolean
Whether existing destination item shall be overwritten.
Type: ITHit.WebDAV.ClientLockUriTokenPair
Lock tokens for destination folder or items to be overwritten if overwrite is true.

Return Value

Type: Task

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

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.
string license = "<?xml version='1.0' encoding='utf...
WebDavSessionAsync session = new WebDavSessionAsync(license);
session.Credentials = new NetworkCredential("User1", "pwd");
IHierarchyItemAsync file1 = await session.OpenFileAsync(new Uri("http://server:8080/Library/image007.gif"));
LockInfo lockInfo1 = await file1.LockAsync(LockScope.Exclusive, false, "User 1", new TimeSpan(0, 5, 0));
IHierarchyItemAsync file2 = await session.OpenFileAsync(new Uri("http://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;

IFolderAsync itemSrc = await session.OpenFolderAsync(new Uri("http://server:8080/Sales/Library/"));
IFolderAsync itemDst = await session.OpenFolderAsync(new Uri("http://server:8080/Library/"));

   await itemSrc.CopyToAsync(itemDst, itemSrc.DisplayName, true, true, locks);
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 copy.
        Console.WriteLine(resp.Href + " " + resp.Status.Code + " " + resp.Status.Description);
See Also