1. 论坛系统升级为Xenforo,欢迎大家测试!
    排除公告

搞了两个小时,ASP遍历文件及文件夹是一点问题了没有了,问题是

本帖由 notnull2006-04-13 发布。版面名称:后端开发

  1. notnull

    notnull New Member

    注册:
    2005-09-27
    帖子:
    11,720
    赞:
    37
    我不熟悉XML

    不会按XML需要的标准把文件列表添加到XML里

    :mummy:
    倒……
     
  2. 不学无术

    不学无术 Ulysses 的元神

    注册:
    2005-08-31
    帖子:
    16,714
    赞:
    39
    音乐文件 XML 的格式大致上可能是

    HTML:
    <?xml version="1.0" encoding="utf-8" ?>
    <playlist>
      <item>
        <title></title>
        <author></author>
        <url></url>
      </item>
      ....
    </playlist>
    那么你只要根据找到的音乐信息来重复生成<item> 节点就可以了。

    原理如此。
     
  3. notnull

    notnull New Member

    注册:
    2005-09-27
    帖子:
    11,720
    赞:
    37
    试试……
    图片的也一样去搞……
     
  4. 西子宜

    西子宜 Well-Known Member

    注册:
    2005-09-05
    帖子:
    15,739
    赞:
    62
    ???
     
  5. 笑笑而飞

    笑笑而飞 New Member

    注册:
    2005-11-22
    帖子:
    1,501
    赞:
    11
    噢!!拿什么蒸救你朋友!
     
  6. notnull

    notnull New Member

    注册:
    2005-09-27
    帖子:
    11,720
    赞:
    37
    ;)

    你以身相许就能拯救我了
     
  7. 老林

    老林 New Member

    注册:
    2005-09-06
    帖子:
    10,580
    赞:
    36
    ....
     
  8. 小叶

    小叶 New Member

    注册:
    2005-09-04
    帖子:
    17,941
    赞:
    33
    遍历文件夹,echo

    PHP:
    <?php
    class listfile{

    var 
    $callFunc;  //操作函数,用于lisDirTree里的调用
    var $extname;  //有效文本文件的扩展名。

    function listfile()
    {
     echo 
    'initialize filetree<BR>';
    // end func

    /** 函数 listDirTree( $dirName = null )
    * 功能 对目录下所有文件及子目录下所有文件进行操作
    * 参数 $dirName 目录名称
    */
    function listDirTree$dirName null )
    {
    //global $tree;

    if( empty( $dirName ) )
    exit( 
    "IBFileSystem: directory is empty." );

    if( 
    is_dir$dirName ) )
    {
    if( 
    $dh opendir$dirName ) )
    {
    //$tree = array();

    while( ( $file readdir$dh ) ) !== false )
    {
    if( 
    $file != "." && $file != ".." )
    {
    $filePath $dirName "/" $file;

    if( 
    is_dir$filePath ) )//为目录,递归
    {
     
    //$tree[$file] = $this->listDirTree( $filePath );
     
    $this->listDirTree$filePath );
    }
    else
    //为文件,进行处理
    //echo "文件处理函数为 $this->callFunc <BR>";
     
     
    eval($this->callFunc);

    //$tree[] = $file;
    //文件处理结束
    }
    }
    closedir$dh );

    }
    else
    {
    exit( 
    "IBFileSystem: can not open directory $dirName.");
    }

    //返回当前的$tree
    //return $tree;
    }

    else
    {
    exit( 
    "IBFileSystem: $dirName is not a directory.");
    }
    }
    //</listDirTree>

    /**
    * mkdirp is used to instead of mkdir ,mkdirp can create deep multiple directory.
    */
    function mkdirp($target) {
      
    // If the path already exists && is a directory, all is well.
      // If the path is not a directory, we've a problem.
      
    if (file_exists($target)) {
       if (!
    is_dir($target)) return false;
       else return 
    true;
      }

      
    // Attempting to create the directory may clutter up our display.
      
    if ( @mkdir($target) ) return true;

      
    // If the above failed, attempt to create the parent node, then try again.
      
    if ( $this->mkdirp(dirname($target)) ) return $this->mkdirp($target);

      return 
    false;
    }
    //</function mkdirp>

    }//</class listfile>
    ?>


     


    echo.php

    <?php
    function echot(&$str){
    echo 
    '<TEXTAREA NAME="" ROWS="5" COLS="80">'.$str.'</TEXTAREA>';
    }

    /**
    * echothead
    */
    function echothead()
    {
     echo 
    '<TEXTAREA NAME="" ROWS="20" COLS="80">';  
    // end func echothead

    /**
    *  echotfoot
    */
    function echotfoot()
    {
        echo 
    "</textarea>";
    // end func

    function pr(&$row){
    echo 
    "<pre>";
    print_R($row);
    }
    function 
    echosql($q){
    $q str_replace("#_","mos",$q);
    echo 
    "$q <br/>\n";
    }
    function 
    echoredsql($q){
    $q str_replace("#_","mos",$q);
    echo 
    "<font color=red> $q </font>\n";
    }
    function 
    echored($str){
    echo 
    "<font color=red> $str </font>\n";
    }
    /**
     * show table,$rows is get by $database->loadOjbectLIst();
    */
    function rowstable(&$rows)
    {
    $n=count($rows);
    if (
    $n>0) {
      
    //pr($rows);
      
    $obj $rows[0];
     
    $fields=get_object_vars($obj) ;// pr($fields);
        
    $cnt "<table class=\"dxtable\">\n";
     for (
    $i=0;$i<$n ;$i++ ) { 
            
    $cnt .="<tr>\n";
      foreach(
    $fields as $key=>$value){
       
    //echo "$key=$value";
          
    $cnt .= "<td>".$rows[$i]->$key."</td>\n";
      }
      
    $cnt .="</tr>\n";
        }
     
    $cnt.="</table>\n";
     echo 
    $cnt;
    }
    // end func


    /**
    *  prt
    */
    function prt($arr)
    {
    echothead();
    print_R($arr);
    echotfoot();
    // end func
    ?>

     
     
  9. amt

    amt New Member

    注册:
    2005-12-13
    帖子:
    8,582
    赞:
    67
    HTML:
    <%@ 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:盘
    %>
     
  10. notnull

    notnull New Member

    注册:
    2005-09-27
    帖子:
    11,720
    赞:
    37

    还要楼上几个说
    遍历文件夹早弄出来了
     
  11. 笑笑而飞

    笑笑而飞 New Member

    注册:
    2005-11-22
    帖子:
    1,501
    赞:
    11
    特此声明:

    请大家以后不要睢不起楼主!!
     
  12. 小叶

    小叶 New Member

    注册:
    2005-09-04
    帖子:
    17,941
    赞:
    33
    :(