Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Moves the folder and its contents to a new folder at the specified URL.
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online
Syntax
'Declaration
Public Sub MoveTo ( _
strNewUrl As String _
)
'Usage
Dim instance As SPFolder
Dim strNewUrl As String
instance.MoveTo(strNewUrl)
public void MoveTo(
string strNewUrl
)
Parameters
strNewUrl
Type: System.StringA string that specifies the URL for the new folder.
Remarks
The MoveTo method applies only to the context of a single site.
Examples
The following code example moves a specified subfolder in the site from one folder into another folder.
Dim site As SPWeb = SPControl.GetContextWeb(Context)
If site.GetFolder("Shared Documents/Source_Subfolder_Name").Exists Then
Dim moveFolder As SPFolder = web.GetFolder
("Shared Documents/Source_Subfolder_Name")
moveFolder.MoveTo("DocLib_Name/Destination_Subfolder_Name")
End If
SPWeb oWebsite = SPContext.Current.Web;
if (oWebsite.GetFolder("Shared Documents/Source_Subfolder_Name").Exists)
{
SPFolder oFolderSrc = oWebsite.GetFolder("Shared Documents/Source_Subfolder_Name");
oFolderSrc.MoveTo("DocLib_Name/Destination_Subfolder_Name");
}