- ·上一篇文章:适合所有表的添加、删除、修改的函数
- ·下一篇文章:ASP转化ip地址为长整型数字
fso实现整个文件夹内容的复制到另一个文件夹中
这里是一个实现将一个文件夹中的内容,包括子文件夹中的内容,复制到另一个文件夹中的asp代码。在使用的过程中要将文件夹的相对路径转换成绝对路径。转换的方法是使用server.mappath。
<
%
startfile_1="
d:\aaa"
 
&
#39
原始文件夹
tofile_1="
c:\bbb"
 
&
#39
目标文件夹
Call 
copyfile(startfile_1,tofile_1)
response.write 
"
完成"
function 
copyfile(startfile,tofile) 
&
#39
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&
#39
复制里面的文件
s=Split(thing,"
\"
)
a=UBound(s)
s3=Split(thing,"
\"
)(a)
MyFileObject.CopyFile 
thing,tofile&
#38
"
\"
&
#38
s3
Next
For 
Each 
thing 
in 
MyFolder.SubFolders&
#39
复制子文件夹
s=Split(thing,"
\"
)
a=UBound(s)
s3=Split(thing,"
\"
)(a)
response.write 
thing&
#38
"
"
response.write 
s1&
#38
"
\"
&
#38
domain&
#38
"
\"
&
#38
s3
response.write 
"
"
MyFileObject.copyFolder 
thing,tofile&
#38
"
\"
&
#38
s3
Next
end 
function
%>
<
%
startfile_1="
d:\aaa"
 
&
#39
原始文件夹
tofile_1="
c:\bbb"
 
&
#39
目标文件夹
Call 
copyfile(startfile_1,tofile_1)
response.write 
"
完成"
function 
copyfile(startfile,tofile) 
&
#39
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&
#39
复制里面的文件
s=Split(thing,"
\"
)
a=UBound(s)
s3=Split(thing,"
\"
)(a)
MyFileObject.CopyFile 
thing,tofile&
#38
"
\"
&
#38
s3
Next
For 
Each 
thing 
in 
MyFolder.SubFolders&
#39
复制子文件夹
s=Split(thing,"
\"
)
a=UBound(s)
s3=Split(thing,"
\"
)(a)
response.write 
thing&
#38
"
"
response.write 
s1&
#38
"
\"
&
#38
domain&
#38
"
\"
&
#38
s3
response.write 
"
"
MyFileObject.copyFolder 
thing,tofile&
#38
"
\"
&
#38
s3
Next
end 
function
%>
fso实现整个文件夹内容的复制到另一个文件夹中