Copy document

Copying a document

 

[C#]

 

// Tree provider

CMS.TreeEngine.TreeProvider provider = new CMS.TreeEngine.TreeProvider(CMS.CMSHelper.CMSContext.CurrentUser);

// Get document (node) which will be copied

TreeNode node = provider.SelectSingleNode(CMS.CMSHelper.CMSContext.CurrentSiteName, "/Products/PDAs/ItemA", "en-us");

// Get target node under which the document will be copied

TreeNode target = provider.SelectSingleNode(CMS.CMSHelper.CMSContext.CurrentSiteName, "/Products/Notebooks", "en-us");

 

if ((target != null) && (node != null))

{

  // copy the document under the specified target,

  // the third parameter says that document`s child nodes (if any) will not be copied

  provider.CopyNode(node, target.NodeID, false);

}