FileSystemObject.CopyFile Method (VB6)

Named Arguments

Yes

Syntax

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).

Description

Copies a file or files from one folder to another.

Rules at a Glance

  • The default value for OverwriteFiles is True.

  • 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.

Programming Tips and Gotchas

  • 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.

See Also

FileSystemObject.CopyFolder Method, Folder.Copy Method
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.220.43.134