FileSystemObject.CopyFile Method (VB6) |
Yes
oFileSysObj.CopyFile Source, Destination [, OverwriteFiles]
oFileSysObj
Use: Required
Data Type: FileSystemObject object
Any object variable returning a FileSystemObject object.
Source
Use: Required
Data Type: String
The path and name of the file to be copied.
Destination
Use: Required
Data Type: String
The path and optionally the filename of the copy to make.
OverwriteFiles
Use: Optional
Data Type: Boolean
Flag indicating whether an existing file is to be overwritten (True) or not (False).
Copies a file or files from one folder to another.
The source path can be relative or absolute.
The source filename can contain wildcard characters; the source path can't.
Wildcard characters can't be included in Destination.
If the destination path or file is read-only, the CopyFile method fails, regardless of the value of OverwriteFiles.
If OverwriteFiles is set to False and the file exists in Destination, a trappable error—runtime error 58, "File Already Exists"—is generated.
If an error occurs while copying more than one file, the CopyFile function exits immediately, thereby leaving the rest of the files uncopied. There is no roll-back facility to undo copies made prior to the error.
If the user has adequate rights, the source or destination can be a network path or share name. For example:
CopyFile "c:Rootone*.*", "\NTSERV1d$RootTwo" CopyFile "\NTSERV1RootTest est.txt", "c:RootOne"
The CopyFile method copies a file or files stored in a particular folder. If the folder itself has subfolders containing files, the method doesn't copy these; use the CopyFolder method.