Copy an item and its descendants

Version: 10.4

You can use the Sitecore.Data.Items.Item.CopyTo method to copy an item and its descendants. For example, to copy the /Sitecore/Content/Home item and any descendants in the Master database to create /Sitecore/Content/Sibling:

RequestResponse
Sitecore.Data.Database master = Sitecore.Configuration.Factory.GetDatabase("master");

Sitecore.Data.Items.Item home = master.GetItem("/sitecore/content/home");

Sitecore.Data.Items.Item content = master.GetItem(Sitecore.ItemIDs.ContentRoot);

home.CopyTo(content,"Sibling");

Do you have some feedback for us?

If you have suggestions for improving this article,