MoveTo(String, Boolean) Method

The MoveTo method of the SPFile class moves the file to the destination URL but overwrites an existing file of the same name only if bOverwrite is true.

Parameters

strNewUrl    A string that contains the destination URL.

bOverWrite    true to overwrite an existing file of the same name; otherwise, false.

Remarks

The MoveTo method is used to move files to another location within the same site.

This method returns an error if bOverWrite is set to false and a file of the same name already exists at the new location.

Example

The following code example moves all files by a specified author from one folder to another folder.

The For loop in the example counts downward (i--) instead of upward (i++) since the files are being moved from the folder and the number of files decreases with each increment.

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