Copy Method

       

Copies the specified object to a designated URL. During the copy process you can choose to update hyperlinks or force a file overwrite if the specified object has the same name as the designated object.

expression.Copy(DestinationUrl, UpdateLinks, ForceOverwrite)

expression   An expression that returns a WebFile or WebFolder object.

DestinationUrl   Required String. The target URL.

UpdateLinks   Optional Boolean. Specifies whether links are to be updated during the copy process. True (default) to update links.

ForceOverwrite   Optional Boolean. Specifies whether to force a file overwrite when a file or folder is found with the same name. Set the argument to True to force a file overwrite. Default value is False.

Remarks

The Copy method only copies files or folders within the same web. You cannot copy across webs. However, you can use the SaveAs method for the PageWindowEx object to save a page that has its file currently located in one web to save the page to a file in another web. Or, you can use the Add method for the WebFile object to add a file that is currently located in one web to another web.

Example

This example copies a file from the Rogue Cellars web folder to an Inventory folder within the same web.

Note To run this example, you must have a web called "C:\My Documents\My Webs\Rogue Cellars" (for a server running on Microsoft Windows) or "C:\WINNT\Profiles\logon alias\Personal\My Webs\Rogue Cellars" (for a server running on Windows NT).

Private Sub FileCopy()
    Dim myFile As WebFile

    Set myFile = ActiveWeb.RootFolder.Files("Zinfandel.htm")
    myFile.Copy "C:\My Webs\Rogue Cellars\Inventory\Zinfandel.htm"
End Sub