Storages & Files CopyFile
CopyFile method 

Copies file (or files if wildcards are used) into the file system.


object.CopyFile( source, destination [, fReplace = True])


source - Source file full path name or path with wildcards.

destination - Destination full path name of a file or directory. No wildcards are allowed in this parameter. If wildcards are used in the source parameter the destination should be a directory.

fReplace - Optional Boolean flag. The default value is True. Indicates if file replace is allowed in the destination if a file with the same name already exists in that location.


Set sf = Server.CreateObject("newObjects.utilctls.SFMain")
' Copy all the text files
' Copy a.txt into b.txt file


If fReplace is set to False the method will fail if a file with the same name exists in the destination location.

Using full path names for both source and the destination allows the application to copy the selected file under new file name.

If wildcards are used in the source and a full file path (not directory) is used in the destination parameter no error will occur but the source files matching the wildcards will be copied one by one over the same file and the last one will remain as result.

For copy/move operations across the different storage types see the members of SFStorage and SFStream objects.

If the parameters contain non-full path names (file names or relative paths) they are assumed relative to the current work directory as usual. However most script host applications (except WSH) does not allow the scripts to set current work directory because typically many scripts may run in the same host and the "work directory" is a process wide term. The scripts shall use full paths composed or calculated through the host supplied routines (for example Server.MapPath in ASP/ALP).

Applies to: SFMain object

See also: SFStorage.CopyElementTo, SFStorage.CopyTo, SFStorage.MoveElementTo, SFStream.CopyTo

Supported on:

Windows 95/NT and later
Windows CE 3.0 and later
Pocket PC/Windows Mobile 2003 and later
Windows CE.NET 4 and later


newObjects Copyright 2001-2006 newObjects [ ]