Plumtree EDK (Enterprise Web Development Kit) 5.4.0 |

# IDocumentManager.CopyToFolder Method

Copies documents and folders from a source parent folder to a target folder.

void CopyToFolder(
IDocumentFolder sourceParentFolder,
IDocumentFolder targetFolder,
IDocument[] documentsToCopy,
IDocumentFolder[] foldersToCopy,
bool inheritSecurity,
string documentHistoryComment
);

#### Parameters

sourceParentFolder
  The source parent document folder to copy from. Each of the source objects must be from this parent folder. Cannot be `null`.
targetFolder
  The target folder. This folder may be in a different project from the source objects. Cannot be `null`.
documentsToCopy
  The documents to copy. Each of the documents must be from the sourceParentFolder and the user must have permission to copy each document. Cannot be `null`.
foldersToCopy
  The document folders to copy. Each of the folders must be from the sourceParentFolder and the user must have permission to copy each folder. All objects in these folders will be copied recursively. Cannot be `null`.
inheritSecurity
  A boolean value indicating how the access level of each objects should be set. If this parameter is `true` the copied objects will inherit security from the targetFolder. If this parameter is `false` the copied objects will be given the same access level as the source objects. If the target folder is in a different project from the source objects, then security is mapped isomorphically from the source project to the target project. Thus if the ProjectMember role in the source project has access level `i` on object `O` and object `O` is copied to object `O'`, then the ProjectMember role in the target project will have access level `i` on object `O'`. Similarly with the ProjectGuest role.
documentHistoryComment
  A string that will be used as the initial comment in the document history of each of the copied documents. Cannot be `null`.

#### Remarks

The operation is recursive in that the entire document tree below each of the given folders to be copied will also be copied. If any name collisions occur, the name of the copied object will be modified to make it unique. This method will make a best-attempt to finish the copy operation. If an error occurs while copying one of the documents or folders, the copying will continue, and a `MultipleException` will be thrown specifying the objects which caused failures.

#### Exceptions

Exception Type | Condition
--- | ---
CollaborationException | The method call resulted in an error or the user does not have access to the folder.
SoapException | There is a communication problem during the execution of the remote method call.
InvalidOperationException | Any of the objects have not yet been stored or have already been removed.
MultipleObjectException | Errors occurred while copying. Each source exception can be retrieved from this exception.

#### See Also

IDocumentManager Interface | Plumtree.Remote.PRC.Collaboration.Document Namespace