Export (0) Print
Expand All

SPFolder.CopyTo Method

Windows SharePoint Services 3

Copies the folder and its contents into a new folder at the specified URL.

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

public void CopyTo(
	string strNewUrl
)

Parameters

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

The CopyTo 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 copies a specified subfolder from the Shared Documents document library to a new subfolder in another document library.

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

Community Additions

ADD
Show:
© 2014 Microsoft