FileSystemObject.CopyFolder Method (VB6) |
Yes
oFileSysObj.CopyFolder 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 folder to be copied from.
Destination
Use: Required
Data Type: String
The path for the folder where the copy is to be made.
OverwriteFiles
Use: Optional
Data Type: Boolean
Flag indicating whether existing files are to be overwritten (True) or not (False).
Copies the contents of a folder, including its subfolders, to another location.
Source must end with either a wildcard character or no path separator.
Wildcard characters can be used in Source, but only for the last component.
Wildcard characters can't be used in Destination.
All subfolders and files contained within the source folder are copied to Destination unless disallowed by the wildcard characters. That is to say, the CopyFolder method is recursive.
If Destination ends with a path separator, or Source ends with a wildcard, CopyFolder assumes that the folder stated in Source exists in Destination or should otherwise be created. For example, given the following folder structure:
C: Rootone SubFolder1 SubFolder2 RootTwo
CopyFolder "c:Rootone*", "C:RootTwo" produces this folder structure:
C: Rootone SubFolder1 SubFolder2 RootTwo SubFolder1 SubFolder2
CopyFolder "c:Rootone", "C:RootTwo" produces this folder structure:
C: Rootone SubFolder1 SubFolder2 RootTwo Rootone SubFolder1 SubFolder2
If the destination path or any of the files contained in Destination are set to read-only, the CopyFolder method fails, regardless of the value of Overwrite.
If OverwriteFiles is set to False, and the source folder or any of the files contained in Source exists in Destination, a trappable error—runtime error 58, "File Already Exists"—is generated.
If an error occurs while copying more than one file or folder, the CopyFolder function exits immediately, leaving the rest of the folders or files uncopied. There is also no roll-back facility to undo the copies prior to the error.
If the user has adequate rights, both the source or destination can be a network path or share name. For example:
CopyFolder "c:Rootone", "\NTSERV1d$RootTwo" CopyFolder "\NTSERV1RootTest", "c:RootOne"