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.
The CopyTo method of the SPFile class copies the file to the destination URL but does not overwrite an existing file of the same name.
strNewUrl A string that specifies the destination URL.
The CopyTo method is used to copy files to another location within the same site. To copy files to a location in another site, use one of the Add methods of the SPFileCollectionclass.
This method returns an error if a file of the same name already exists at the new location.
The following code example copies files from one document library into another one if the files are checked into the original library with the comment "Complete".
This example requires using directives (Imports in Visual Basic) for both the Microsoft.SharePoint and Microsoft.SharePoint.WebControls namespaces.
Platforms: Microsoft Windows Server 2003
Security: Code Access Security