Code
'遍历文件夹sub ListFolderContents(path) dim fs, folder, file, item, url set fs = CreateObject("Scripting.FileSystemObject") set folder = fs.GetFolder(path) Response.Write("<li><b>" & folder.Name & "</b> - " & folder.Files.Count & " files, " & folder.SubFolders.Count & " directories." & vbCrLf & "<ul>" & vbCrLf) for each item in folder.SubFolders ListFolderContents(item.Path) next for each item in folder.Files Response.Write("<li><a href=""" & MapURL(item.path) & """ target='_blank'>" & item.Name & "</a> - " & item.path & "</li>" & vbCrLf) next Response.Write("</ul>" & vbCrLf) Response.Write("</li>" & vbCrLf)end subfunction MapURL(path) MapURL = Replace(Right(path, Len(path) - Len(Server.MapPath("/"))), "\", "/")end functionListFolderContents("D:\web\")
转载于:https://www.cnblogs.com/cloudgamer/articles/1219299.html
相关资源:asp.net 遍历指定文件夹的所有文件