Chức năng: Copy một file hoặc một folder
Ngôn ngữ: asp - Nhóm: file_folder
CÚ PHÁP
FileCopy source, destination
Copy file hoặc folder.
Cần thiết có 2 đối số:
Source:file/folder nguồn.
destination: Đích.
Chú ý: Cần đối số nguồn và đích với đường dẫn đầy đủ !
VÍ DỤ
<%
'--- 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 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
%>