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.
Copies the folder and its contents into 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 CopyTo ( _
strNewUrl As String _
)
'Usage
Dim instance As SPFolder
Dim strNewUrl As String
instance.CopyTo(strNewUrl)
public void CopyTo(
string strNewUrl
)
Parameters
strNewUrl
Type: System.StringA string that specifies the URL for the new folder.
Remarks
The CopyTo method applies only to the context of a single site.
Examples
The following code example copies a specified subfolder from the Shared Documents document library to a new subfolder in another document library.
Dim site As SPWeb = SPControl.GetContextWeb(Context)
If site.GetFolder("Shared Documents/Source_Subfolder_Name").Exists Then
Dim copyFolder As SPFolder = site.GetFolder
("Shared Documents/Source_Subfolder_Name")
copyFolder.CopyTo("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.CopyTo("DocLib_Name/Destination_Subfolder_Name");
}