Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

ASP Copy Method

ASP Copy Method


File Object Reference Complete File Object Reference Manual


The Copy method copies a specified file or folder from one location to another.

**Note:** Applying the Copy method to a File or Folder produces exactly the same result as using FileSystemObject.CopyFile or FileSystemObject.CopyFolder. In FileSystemObject.CopyFile or FileSystemObject.CopyFolder, use object to reference the file or folder, and pass the file or folder as an argument to FileSystemObject.CopyFile or FileSystemObject.CopyFolder. It should be noted, however, that the FileSystemObject.CopyFile or FileSystemObject.CopyFolder methods can copy multiple files or folders.

Syntax

FileObject.Copy(destination[,overwrite])

FolderObject.Copy(destination[,overwrite])

Parameters Description
destination Required. The destination for copying the file or folder. Wildcards are not allowed.
overwrite Optional. A Boolean value indicating whether existing files or folders can be overwritten. True means the file/folder can be overwritten; false means the file/folder cannot be overwritten. The default is true.

Example for the File object

<%

dim fs,f

set fs=Server.CreateObject("Scripting.FileSystemObject")

set f=fs.GetFile("c:\test.txt")

f.Copy("c:\new_test.txt",false)

set f=nothing

set fs=nothing

%>

Example for the Folder object

<%

dim fs,fo

set fs=Server.CreateObject("Scripting.FileSystemObject")

set fo=fs.GetFolder("c:\test")

fo.Copy("c:\new_test",false)

set fo=nothing

set fs=nothing

%>


File Object Reference Complete File Object Reference Manual