asp复制文件夹代码
时间:2022-05-25 09:42:40|栏目:ASP代码|点击: 次
复制代码 代码如下:
<%
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""&CopyMyFolder(FolderName,FolderPath)&"" '复制文件夹2006下的所有内容到2008文件夹下并返回结果
%>