比如现有文件夹A,
其下有A1,A2,....An ,等文件夹
也可能在A1,A2...An下还有N个子文件夹,现在只想从A文件下搜索出所有的Data.xml文件来,并输出每个Data.xml文件的路径信息^_^
比如Data.xml在F:\web\car\Export\Alfa\Alfa目录下,那么只需要保存此路径即可^_^
因为这个路径信息对我很有用呵呵,只有10分拉^_^,不好意思.

解决方案 »

  1.   

    asp的方法可以^_^,大家不防用asp.net实现一下^_^<%@ Language=VBScript %>
    <%
        function bianli(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
                    
                set objFiles=objSubFolder.Files            for each objFile in objFiles
    if objFile.name="Data.xml" then
                    Response.Write nowpath&"+++"&objFile.name
    end if
                next
                Response.Write "<p>"
                bianli(nowpath)
    ' 递归方法
                
            next 
            set objFolder=nothing
            set objSubFolders=nothing
            set fso=nothing
        end function
    %>
    <%
        bianli("F:\") 
    %>
      

  2.   

    实现方法大同小异
    用directory提供的方法
    也是用递归实现
    Directory.GetDirectories

    Directory.GetFiles
      

  3.   

    现在我用asp的方法解决发,又发现一个问题
    就是ASP里面如何向asp.net中传递参数
    比如:test.asp
    Response.redirect "GetPageHtml.aspx?str="&str
    我传过去好像没值^_^
      

  4.   

    <%@ Language=VBScript %>
    <%
        function bianli(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
                    
                set objFiles=objSubFolder.Files            for each objFile in objFiles
           if objFile.name="Data.xml" then
                   nowpath=replace(nowpath,"\","/")
                        str=str&nowpath&"/,"
          end if
                next
               
                bianli(nowpath)
     
            next 

            str=replace(str,"E:/GetPageHtml/","")
            '这里可以正常输出str=car/Export/Alfa/Alfa/,car/,
    Response.write str
    '当我用redirect重定向到另一个ASPX页面的时候发现:
    '这个字符串的值竟然传不过去^_^,为什么,请高手指点,谢谢
    Response.redirect "GetPageHtml.aspx?str="&str
            set objFolder=nothing
            set objSubFolders=nothing
            set fso=nothing
        end function
    %>
    <%
        bianli("E:\GetPageHtml") 
    %>
      

  5.   

    <%
    str="ChangAnZhiXing/,car/China/ChangAnQiChe/,car/China/nnn/," 
    Response.redirect "GetPageHtml.aspx?str="&str
    %>
    这样可以啊传过去啊
      

  6.   

    <%
    str="ChangAnZhiXing/,car/China/ChangAnQiChe/,car/China/nnn/," 
    Response.redirect "GetPageHtml.aspx?str="&str
    %>
    你这样是可以啊传过去啊
    关键是一放到我函数里面去就穿不过去了啊,晕哦
      

  7.   

    现在用。net方法,但只能输出一级目录下的文件
    string[] FileNames = Directory.GetFiles(this.Server.MapPath(@"car\"));
    if(FileNames.Length > 0)
    {
    for(int i=0;i<FileNames.Length;i++)
    {
    string[] files = FileNames[i].Trim().Split('\\');
    string filesname = files[files.Length-1].Trim();
    this.Response.Write(filesname +"<br/>");
    }}
      

  8.   

    大家帮我看看啊,
    现在用。net方法,但只能输出一级目录下的文件
    string[] FileNames = Directory.GetFiles(this.Server.MapPath(@"car\"));
    if(FileNames.Length > 0)
    {
    for(int i=0;i<FileNames.Length;i++)
    {
    string[] files = FileNames[i].Trim().Split('\\');
    string filesname = files[files.Length-1].Trim();
    this.Response.Write(filesname +"<br/>");
    }}
    现在的要求是将所有的文件夹下的文件名都输出来,谢谢