Copies a specified file or folder from one location to another.
|
---|
object.Copy( destination[, overwrite] ); |
Arguments
- 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
Example
The following example illustrates the use of the Copy method.
JScript | Copy Code |
---|
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");
|
Visual Basic Script | Copy Code |
---|
Dim fso, MyFile
Set 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") |
See Also