精典ASP遍历文件文件夹(ASP遍历) - TOMMYHU - 专注互联网开发及运营技术,提供相关资料及软件下载,奇趣网络时事评论!
Mar 9

精典ASP遍历文件文件夹(ASP遍历) 不指定

tommyhu , 13:55 , ASP , Comments(0) , Trackbacks(0) , Reads(9088) , Via Original Large | Medium | Small
精典ASP遍历文件文件夹(ASP如何遍历)

<%@ Language=VBScript %>
<%
    function bianli(path)
        dim fso            'fso对象
     &nbsp;  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("F:\") '调用bianli()函数,这里是遍历F:盘
%>


▲返回顶部

Add a comment

Nickname

emotemotemotemotemotemotemotemotemotemotemotemotemotemotemotemot