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文件夹下并返回结果
%>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/3338.html