asp复制文件夹代码
程序员文章站
2023-10-20 12:29:26
复制代码 代码如下:<% function copymyfolder(foldername,folderpath) sfolder=server.mappa...
复制代码 代码如下:
<%
function copymyfolder(foldername,folderpath)
sfolder=server.mappath(foldername)
ofolder=server.mappath(folderpath)
set fso=server.createobject("scripting.filesystemobject")
if fso.folderexists(server.mappath(foldername)) then'检查原文件夹是否存在
if fso.folderexists(server.mappath(folderpath)) then'检查目标文件夹是否存在
fso.copyfolder sfolder,ofolder
else '目标文件夹如果不存在就创建
createnewfolder = server.mappath(folderpath)
fso.createfolder(createnewfolder)
fso.copyfolder sfolder,ofolder
end if
copymyfolder="复制文件夹["&server.mappath(foldername)&"]到["&server.mappath(folderpath)&"]成功!"
else
copymyfolder="错误,原文件夹["&sfolde&"]不存在!"
end if
set fso=nothing
end function
foldername="2006" '原文件夹
folderpath="2008" '目标文件夹
response.write""©myfolder(foldername,folderpath)&"" '复制文件夹2006下的所有内容到2008文件夹下并返回结果
%>
上一篇: 肺部手术后吃什么好?这些知识你要知道!