Sun Chili!Soft ASP Sun Chili!Soft
ASP Sun Microsystems

 

JScript FileSystemObject Object CopyFolder Method

Recursively copies a folder from one location to another.

Syntax: JScript FileSystemObject Object CopyFolder Method

object.CopyFolder ( source, destination[, overwrite] );

Arguments: JScript FileSystemObject Object CopyFolder Method

object

The name of a FileSystemObject. Required.

source

A character string folder specification, which can include wildcard characters, for one or more folders to be copied. Required.

destination

A character string destination where the folder and subfolders from source are to be copied. Wildcard characters are not allowed. Required.

overwrite

A Boolean value that indicates if existing folders are to be overwritten. If True, files are overwritten; if False, they are not. The default is True. Optional.

Remarks: JScript FileSystemObject Object CopyFolder Method

Wildcard characters can only be used in the last path component of the source argument. For example, you can use:

fs = new ActiveXObject("Scripting.FileSystemObject");

fs.CopyFolder ("c:\\mydocuments\\letters\\*",

"c:\\tempfolder\\")

But you can't use:

fs = new ActiveXObject("Scripting.FileSystemObject");

fs.CopyFolder ("c:\\mydocuments\\*\\*", "c:\\tempfolder\\")

If source contains wildcard characters or destination ends with a path separator (\), it is assumed that destination is an existing folder in which to copy matching folders and subfolders. Otherwise, destination is assumed to be the name of a folder to create. In either case, four things can happen when an individual folder is copied:

·   If destination does not exist, the source folder and all its contents gets copied. This is the usual case.

·   If destination is an existing file, an error occurs.

·   If destination is a directory, an attempt is made to copy the folder and all its contents. If a file contained in source already exists in destination, an error occurs if overwrite is false. Otherwise, it will attempt to copy the file over the existing file.

·   If destination is a read-only directory, an error occurs if an attempt is made to copy an existing read-only file into that directory and overwrite is false.

An error also occurs if a source using wildcard characters doesn't match any folders.

The CopyFolder method stops on the first error it encounters. No attempt is made to roll back any changes made before an error occurs.

Copyright 2002 Sun Microsystems, Inc. All rights reserved. Legal Notice.