Copy method
Copies the specified file or folder from one location to another.
object.Copy destination[, overwrite]
Parameters
Object
Required option. Should be the name of the File or Folder object.
Destination
Required option. The destination where the file or folder is copied. Wildcard characters are not allowed.
Overwrite
Options available. A Boolean value. If the existing file or folder is overwritten, the Boolean value is True(default), or False.
Description
The result of applying the Copy method to File or Folder is exactly the same as the action performed using Filesystemobject.copyfile or Filesystemobject.copyfolder. In Filesystemobject.copyfile or Filesystemobject.copyfolder, use object to refer to a file or folder and pass the file or folder as a parameter to the Filesystemobject.copyfile or Filesystemobject.copyfolder. However, it should be noted that the Filesystemobject.copyfile or Filesystemobject.copyfolder methods can replicate multiple files or folders.
The following example shows the use of the Copy method:
Dim FSO, Myfileset fso = CreateObject ("Scripting.FileSystemObject") Set MyFile = fso. CreateTextFile ("C:\testfile.txt", True) MyFile.WriteLine (" This is a test ") myfile.close Set MyFile = fso. GetFile ("C:\testfile.txt") Myfile.copy ( "C:\windows\desktop\test2.txt" Span class= "CFE" > )