ÄúµÄλÖãº
Ñ°ÃÎÍøÊ×Ò³
£¾
±à³ÌÀÖÔ°
£¾
VBScript
£¾
VBScript
objects
constants
operators
statements
functions
properties
methods
All Objects
FileSystemObject Object
METHOD: FileSystemObject.CopyFile
object.
CopyFile
source, destination [, overwrite]
This method lets us copy one or more files from one location ( the source) to another (destination). Wildcards can be used within the
source
string, providing it is the last component in the path, to enable the copying of multiple files, but cannot be used in the
destination
string. Note that if the
source
does
contain wildcards, it is automatically assumed that the
destination
is an existing folder and any matching files are copied to it.
The
overwrite
parameter is a Boolean.
True
allows the overwriting of existing files in the destination, providing that the permissions on the destination allow it ( if the destination is set as read-only, the
CopyFile
method will fail). An overwrite setting of
False
prevents existing files in the destination from being overwritten.
It is recommended that you use the
FileExists
method when copying or moving a file - if a
source
file doesn't exist you'll get an error.
Code:
<%
dim filesys
set filesys=CreateObject("Scripting.FileSystemObject")
If filesys.FileExists("c:\sourcefolder\anyfile.html") Then
filesys.CopyFile "c:\sourcefolder\anyfile.html", "c:\destfolder\"
End If
%>