当前位置: 首页 > 图文教程 > 网络编程 > ASP > fso实现整个文件夹内容的复制到另一个文件夹中

ASP
用ASP编写网络传呼机
用ASP+CSS实现随机背景
ASP下载系统防盗链方法
用ASP编写下载网页中所有资源的程序
Request.ServerVariables应用
解决Asp程序的Server.CreateObject错误
ASP实现TCP端口扫描的方法
源码实例:ASP实现远程保存图片
用ASP+DLL实现WEB方式修改服务器时间
ASP使用MySQL数据库全攻略
ASP+SQL Server构建网页防火墙
教程/ASP 十天学会ASP之第二天
教程/ASP 十天学会ASP之第四天
教程/ASP 十天学会ASP之第五天
教程/ASP 十天学会ASP之第六天
教程/ASP 十天学会ASP之第七天
教程/ASP 十天学会ASP之第八天
教程/ASP 十天学会ASP之第九天
教程/ASP 十天学会ASP之第十天
关于学习ASP和编程的28个观点

ASP 中的 fso实现整个文件夹内容的复制到另一个文件夹中


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 42 ::
收藏到网摘: n/a

这里是一个实现将一个文件夹中的内容,包括子文件夹中的内容,复制到另一个文件夹中的asp代码。在使用的过程中要将文件夹的相对路径转换成绝对路径。

转换的方法是使用server.mappath。


<%
startfile_1="d:\aaa" '原始文件夹
tofile_1="c:\bbb" '目标文件夹
Call copyfile(startfile_1,tofile_1)
response.write "完成"

function copyfile(startfile,tofile) 'startfile为原始文件夹路径,tofile为目标文件夹路径
Set MyFileObject=Server.CreateObject("Scripting.FileSystemObject")
Set MyFolder=MyFileObject.GetFolder(startfile)
domain=Split(startfile,"\")(UBound(Split(startfile,"\")))
For Each thing in MyFolder.Files'复制里面的文件
s=Split(thing,"\")
a=UBound(s)
s3=Split(thing,"\")(a)
MyFileObject.CopyFile thing,tofile&"\"&s3
Next
For Each thing in MyFolder.SubFolders'复制子文件夹
s=Split(thing,"\")
a=UBound(s)
s3=Split(thing,"\")(a)
response.write thing&"
"
response.write s1&"\"&domain&"\"&s3
response.write "
"
MyFileObject.copyFolder thing,tofile&"\"&s3
Next
end function
%>