IHierarchyItem.MoveTo Method (IFolder, String, Boolean, LockUriTokenPair[])

IT Hit WebDAV for .NET

Moves this item to another location.

[Visual Basic]
Sub MoveTo( _
   ByVal destinationFolder As IFolder, _
   ByVal destinationName As String, _
   ByVal overwrite As Boolean, _
   ByVal lockTokens As LockUriTokenPair() _
)
[C#]
void MoveTo(
   IFolder destinationFolder,
   string destinationName,
   bool overwrite,
   LockUriTokenPair[] lockTokens
);

Parameters

destinationFolder
Folder to move to.
destinationName
Name to assign to moved item.
overwrite
Whether existing destination item shall be overwritten.
lockTokens
Lock tokens for resources to be moved, for destination folder or resources to be overwritten that are locked.

Exceptions

Exception Type Condition
ForbiddenException The source and destination URIs are the same.
ConflictException A resource cannot be created at the destination until one or more intermediate collections have been created.
PreconditionFailedException The destination resource exists and overwrite was false.
LockedException The destination folder or items to be overwritten or source items were locked.
NotFoundException This item doesn't exist on the server.
WebDavHttpException Server returned unknown error for specific resource.
WebDavException Unexpected error occurred.

Example

 string license = "<?xml version='1.0' encoding='utf...
 WebDavSession session = new WebDavSession(license);
 session.Credentials = new NetworkCredential("User1", "pwd");
 IFolder itemSrc = session.OpenFolder(new Uri("http://server:8080/Library/"));
 IFolder itemDst = session.OpenFolder(new Uri("http://server:8080/Sales/"));
 LockInfo lockInfo1 = itemDst.Lock(LockScope.Shared, true, "User 1", new TimeSpan(0, 5, 0));

 IHierarchyItem resource = session.OpenResource(new Uri("http://server:8080/Library/image007.gif"));
 LockInfo lockInfo2 = resource.Lock(LockScope.Exclusive, false, "User 1", new TimeSpan(0, 5, 0));

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

 try
 {
     itemSrc.MoveTo(itemDst, itemSrc.DisplayName, 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 move.
         Console.WriteLine(resp.Href + " " + resp.Status.Code + " " + resp.Status.Description);
     }
 }
 

See Also

IHierarchyItem Interface | ITHit.WebDAV.Client Namespace | IHierarchyItem.MoveTo Overload List