Open In App

ASP CopyFile Method

Last Updated : 23 Feb, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

The ASP CopyFile Method is used to copying one or more files from one place to another place. It is a predefined method of the FileSystem Object.

Syntax:

FileSystemObject.CopyFile source,destination[,overwrite] 

Parameter Values:

  • Source: It is a required attribute. It contains a Character string file that can include wildcard characters, for one or more files to be copied.
  • destination: It is also a required attribute. It specifies a character string value Where to copy the file or files. It does not include wildcard characters.
  • overwrite: It contains a Boolean value which indicates that whether an existing file can be overwritten or not. True, files are overwritten; if False, they are not. The default is True. Note that CopyFile will fail if destination has the read-only attribute set, regardless of the value of overwrite.

Example Code: Below example demonstrates the CopyFile Method. 

ASP




<%
dim gfg
set gfg=Server.CreateObject("Scripting.FileSystemObject")
gfg.CopyFile "c:\Folder1\A\*.txt","c:\Folder2\"
response.write("File is Copied")
set gfg=nothing
%>


Output:

File is Copied 

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads