IHierarchyItem.CopyTo Method (IFolder, String, Boolean, Boolean)

IT Hit WebDAV for .NET

Copies this item to destination folder.

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

Parameters

destinationFolder
Folder to copy to.
destinationName
Name to assign to copied item.
deep
Indicates whether children of this item should be copied.
overwrite
Whether existing destination item shall be overwritten.

Exceptions

Exception Type 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.

Example

 string license = "<?xml version='1.0' encoding='utf...
 WebDavSession session = new WebDavSession(license);
 session.Credentials = new NetworkCredential("User1", "pwd");
 IFolder srcFolder = session.OpenFolder(new Uri("http://server:8080/Library/Sales"));
 IFolder dstFolder = session.OpenFolder(new Uri("http://server:8080/Library/"));

 try
 {
     srcFolder.CopyTo(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 (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.CopyTo Overload List