'xVar:源路径
'yVar:目标路径
'zVar:是否覆盖
Public Function cpdir( xVar, yVar, zVar )
Set Sys = Server.CreateObject("Scripting.FileSystemObject")
If Sys.FolderExists( xVar ) Then
Sys.CopyFolder xVar, root&yVar, zVar
msg ="恭喜,目录复制成功!"
Else
msg ="抱歉,没有找到您想要的目录!"
End If
Set Sys = Nothing
cpdir = msg
End Function
<%
'********************************************************************************************************
'函数名称:CreateFiles(filename,path1)
'作者:Rock E_Mail:mh_rock@163.com
'函数功能:建立一个新文件夹,把指定文件夹的全部文件考入新文件夹
'函数参数:filename(要创建的文件夹的名称,如:"NewFiles" 或 "../NewFile");path1(要考入新文件夹的文件夹相对路径)
'函数实例:CreateFiles("NewFiles","admin")
'********************************************************************************************************
function CreateFiles(filename,path1)
dim filename1,path,fso
set fso=server.CreateObject("scripting.filesystemobject")
filename1=server.mappath(filename)
path=server.mappath(path1)
If Not fso.folderexists(path) then
set fso=nothing
response.write("<script language='javascript'>alert('要拷贝内容的文件夹不存在,请换一个试试'); window.history.go(-1);</script>")
End If
If NOT fso.folderexists(filename1) then
fso.createfolder(filename1)
else
set fso=nothing
response.write("<script language='javascript'>alert('该文件夹已经存在,请换一个试试'); window.history.go(-1);</script>")
End If
set objFolder=fso.GetFolder(path)
set objSubFolders=objFolder.Subfolders
for each objFile in objSubFolders
fso.copyfolder path&"\"&objFile.name,filename1&"\"
next
for each objFile in objFolder.files
fso.copyfile path&"\"&objFile.name,filename1&"\"&objFile.name
next
set objFolder=nothing
set objSubFolders=nothing
set fso=nothing
end function
%>