Share via


CopyTo Method

The CopyTo method of the SPFolder class copies the folder and its contents into a new folder at the specified URL.

Parameters

strNewUrl   A string that specifies the URL for the new folder.

Remarks

The CopyTo method only applies 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.

Example

The following code example copies a specified subfolder from the Shared Documents document library to a new subfolder in another document library.

This example requires using directives (Imports in Visual Basic) for both the Microsoft.SharePoint and Microsoft.SharePoint.WebControls namespaces.

Requirements

Platforms: Microsoft Windows Server 2003

Security: Code Access Security