ASP递归搜索目录下所有文件,包括子目录:

<%
'On Error Resume Next

Function BianLi(Path) '遍历递归搜索所有文件
Dim Fso,ObjFolder,ObjFile 'Fso对象,子目录对象,文件对象
Set Fso=Server.CreateObject("scripting.filesystemObject") '创建FSO读写对象

For Each ObjFile in Fso.GetFolder(Path).Files '读取当前目录下的文件
    Response.Write Path & "\" & ObjFile.Name & " - Size:" & ObjFile.Size & " Bytes<BR>" & Vbcrlf
Next

For Each ObjFolder In Fso.GetFolder(Path).SubFolders '读取子目录
    BianLi(Path & "\" & ObjFolder.Name) '调用递归搜索子目录完整路径
Next
End Function

BianLi(Server.MapPath(".")) '调用遍历函数
%>