Name
File.Copy Method
Syntax
oFileObj.CopyDestination[,OverwriteFiles]
oFileObjUse: Required
Data Type: File object
A File object.
DestinationUse: Required
Data Type: String
The path and, optionally, the filename of the copied file.
OverwriteFilesUse: Optional
Data Type: Boolean
Trueif the copy operation can overwrite an existing file,Falseotherwise.
Description
Copies the file represented by
oFileObj to another location.
Rules at a Glance
Wildcard characters can’t be used in
Destination.
Programming Tips and Gotchas
If the
Destinationpath is set to read-only, the Copy method fails regardless of theOverwriteFilessetting and generates a “Permission denied” error.If
OverwriteFilesisFalseand the file already exists inDestination, runtime error 58, “File Already Exists,” is generated.If the user has adequate rights,
Destinationcan be a network path or share name. For example:MyFile.Copy "\\NTSERV1\d$\RootTwo\" MyFile.Copy "\\NTSERV1\RootTest"
See Also
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access