復制代碼 代碼如下: <% 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文件夾下并返回結果 %>