如何遍历目录及目录下的文件?
<%@ language=vbscript %>
<%
function bianli(path)
set fso=server.createobject("scripting.filesystemobject")
on error resume next
set objfolder=fso.getfolder(path)
set objsubfolders=objfolder.subfolders
for each objsubfolder in objsubfolders
nowpath=path + "\" + objsubfolder.name
response.write nowpath
set objfiles=objsubfolder.files
for each objfile in objfiles
response.write "<br>---"
response.write objfile.name
next
response.write "<p>"
bianli(nowpath)
' 递归方法.
next
set objfolder=nothing
set objsubfolders=nothing
set fso=nothing
end function
%>
<%
bianli("f:")
' 遍历f盘.
%>
下一篇: 如何用表单在线建立目录?