Move an item

Version: 10.4

You can use the Sitecore.Data.Items.Item.MoveTo method to move an item or branch. For example, to move the /Sitecore/Content/Home/Sample item in the Master database to /Sitecore/Content:

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

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

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

sample.MoveTo(content);

Do you have some feedback for us?

If you have suggestions for improving this article,