ASP使用FSO遍历文件函数

by 清泉 20. 八月 2008 10:59

<%@ 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("F:\") '调用bianli()函数,这里是遍历F:盘
%>

Tags:

ASP技术资料 | 学习心得

添加评论



(将显示你的Gravatar头像)  

biuquote
微笑得意调皮害羞酷大笑惊讶发呆喜欢可怜尴尬闭嘴噘嘴皱眉伤心抓狂呕吐坏笑漫骂发怒
Loading



Supidea.com 晨飞的梦 @ All Rights Reserved. Powered by BlogYi.NET ver:1.8.0.0. 苏ICP备09011404号

关于博主

kamau
抱着美好的理想背井离乡,这酸甜苦辣只能默默忍受。既然选择了路,就得风雨兼程……

Calendar

<<  二月 2012  >>
303112345
6789101112
13141516171819
20212223242526
2728291234
567891011

在日历中查看文章

最近的评论

Comment RSS

声明

      本博所发一切破解相关附件只作学习研究交流之用,严禁用于商业用途,请在下载24小时内删除。
      本博所有网友评论不代表本博立场,版权归其作者所有。

© Copyright 2009