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

ASP
查询翻页优化
强制刷新和判断文件地址
asp缓存类
Byval与Byref的区别
全面认识ASP注入技巧
ubbcode函数
newasp中下载类
[ASP]精华代码
由给定的字符串生成关键字
经验几则
转换中文为unicode 转换unicode到正常文本
在ASP应用程序中限制重复提交同一表单
ASP 程序实现自动升级功能
在ASP编程中使用数组
asp组件编写准备工作
利用AdoDb.Stream对象来读取UTF-8格式的文本文件
把字符串转换成数据库SQL语句格式
access中链接表的问题
access数据库的一些少用操作,ASP,创建数据库文件,创建表,创建字段,ADOX
Asp Access 创建静态文件/HTML

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 107 ::
收藏到网摘: 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
%>