FileCopy Statement:
Copies a file or folder.
Description:
The FileCopy statement copies file, directories and folders. There are two required arguments, source and destination. The source argument is the full path to the file you are copying and the destination argument is the full path of where the copied file is to be placed.
Syntax:
FileCopy source, destination
Example:
<%
'--- Copy file.txt from New folder, name the copy file2.txt and put it in the same folder as the original. FileCopy "C:\New Folder\file.txt", "C:\New Folder\file2.txt"
%>
ASP Source Code:
<%
Private Sub FileCopy(byVal source, byVal destination) Dim objFSO, objToCopy, boolErr, strErrDesc On Error Resume Next Set objFSO = Server.CreateObject("scripting.filesystemobject") if instr( right( source, 4 ), "." ) then '--- probably a file Set objToCopy = objFSO.GetFile(source) else '--- probably a directory or folder Set objToCopy = objFSO.GetFolder(source) end if objToCopy.Copy destination if Err Then boolErr = True strErrDesc = Err.Description end if Set objToCopy = Nothing Set objFSO = Nothing On Error GoTo 0 if boolErr then Err.Raise 5104, "FileCopy Statement", strErrDesc End Sub
%>
|