Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

SPFolder.MoveTo Method

Windows SharePoint Services 3

Moves the folder and its contents to a new folder at the specified URL.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

public void MoveTo(
	string strNewUrl


Type: System.String
A string that specifies the URL for the new folder.

The MoveTo method applies only to the context of a single site.

This method raises an error if a folder of the same name as the one specified in the strNewUrl parameter already exists.

The following code example moves a specified subfolder in the site from one folder into another folder.

SPWeb oWebsite = SPContext.Current.Web;
if (oWebsite.GetFolder("Shared Documents/Source_Subfolder_Name").Exists)
    SPFolder oFolderSrc = oWebsite.GetFolder("Shared Documents/Source_Subfolder_Name");


Community Additions

© 2015 Microsoft