dir="/" '请设置你要显示的目录,"/"为整站所有文件,"../"为上级目录下所有文件
set fso = createobject("scripting.filesystemobject")
response.write "指定目录下所有文件及所有子目录下文件显示如下:" & "<br>"
iterate(server.mappath(dir))
function iterate(path)
dim folder, folders, files, file
set folder = fso.getfolder(path)
set files = folder.files
for each file in files
response.write file.path & "<br>"
next
set folders = folder.subfolders
for each f in folders
iterate f.path
next
end function
set fso=nothing
%>
-----------------------------------------------------------------------
CSDN优秀版主评比,请各位兄弟支持我,谢谢-jspadmin
投票地址:http://community.csdn.net/Inquiry/143.htm
<%@ Language=VBScript %>
<%
function bianli(path)
dim fso 'fso对象
dim objFolder '文件夹对象
dim objSubFolders '子文件夹集合
dim objSubFolder '子文件夹对象
dim objFiles '文件集合
dim objFile '文件对象
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("d:") '调用bianli()函数,这里是遍历d:盘
%>