Microsoft® JScript™ Copy Method | Language Reference Version 3

See Also Applies To

##### Description

> Copies a specified file or folder from one location to another.

##### Syntax

> object.Copy( destination[, overwrite] );

> The Copy method syntax has these parts:

> Part | Description
> object | Required. Always the name of a File or Folder object.
> destination | Required. Destination where the file or folder is to be copied. Wildcard characters are not allowed.
> overwrite | Optional. Boolean value that is True (default) if existing files or folders are to be overwritten; False if they are not.

##### Remarks

> The results of the Copy method on a File or Folder are identical to operations performed using FileSystemObject.CopyFile or FileSystemObject.CopyFolder where the file or folder referred to by object is passed as an argument. You should note, however, that the alternative methods are capable of copying multiple files or folders.

> The following example illustrates the use of the Copy method:

> >     var fso, f;
> >     fso = new ActiveXObject("Scripting.FileSystemObject");
> >     f = fso.CreateTextFile("c:\\testfile.txt", true);
> >     f.WriteLine("This is a test.");
> >     f.Close();
> >     f = fso.GetFile("c:\\testfile.txt");
> >     f.Copy("c:\\windows\\desktop\\test2.txt");

© 1998 Microsoft Corporation. All rights reserved. Terms of Use.