Name
File.Copy Method
Syntax
oFileObj
.CopyDestination
[,OverwriteFiles
]
-
oFileObj
Use: Required
Data Subtype: File object
Any object variable returning a File object.
-
Destination
Use: Required
Data Subtype: String
The path and, optionally, the filename of the copied file.
-
OverwriteFiles
Use: Optional
Data Subtype: Boolean
True
if the copy operation can overwrite an existing file,False
otherwise.
Description
Copies the file represented by oFileObj
to
another location.
Rules at a Glance
Wildcard characters can’t be used in
Destination
.
Programming Tips & Gotchas
If the
Destination
path is set to read-only, the Copy method fails regardless of theOverwriteFiles
setting and generates a “Permission denied” error.If
OverwriteFiles
isFalse
and the file already exists inDestination
, runtime error 58, “File Already Exists,” is generated.If the user has adequate rights,
Destination
can be a network path or share name. For example:Copy "\\NTSERV1\d$\RootTwo\" Copy "\\NTSERV1\RootTest"
See Also
FileSystemObject.CopyFile Method |
Get VBScript in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.