用FSO组件可以:
<%
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(objFile.name & "<br>")
next
next
set objFolder=nothing
set objSubFolders=nothing
set fso=nothing
%>
我没有写入数组,而是输出到前台页面上了,你可以根据自己的需要修改
温馨提示:答案为网友推荐,仅供参考