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

<script type="text/javascript"> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
这里是一个实现将一个文件夹中的内容,包括子文件夹中的内容,复制到另一个文件夹中的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
%>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值