Namespace: ITHit.WebDAV.Client
void CopyTo( IFolder destinationFolder, string destinationName, bool deep, bool overwrite, LockUriTokenPair[] lockTokens )
Exception | Condition |
---|---|
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. |
NotFoundException | This item doesn't exist on the server. |
WebDavHttpException | Server returned unknown error for specific resource. |
WebDavException | Unexpected error occurred. |
string license = "<?xml version='1.0' encoding='utf... WebDavSession session = new WebDavSession(license); session.Credentials = new NetworkCredential("User1", "pwd"); IHierarchyItem file1 = session.OpenFile(new Uri("http://server:8080/Library/image007.gif")); LockInfo lockInfo1 = file1.Lock(LockScope.Exclusive, false, "User 1", new TimeSpan(0, 5, 0)); IHierarchyItem file2 = session.OpenFile(new Uri("http://server:8080/Library/image004.gif")); LockInfo lockInfo2 = file2.Lock(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 = session.OpenFolder(new Uri("http://server:8080/Sales/Library/")); IFolder itemDst = session.OpenFolder(new Uri("http://server:8080/Library/")); try { itemSrc.CopyTo(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); } }