帝国软件
  设为首页 加入收藏 关于我们
 
解密帝国网站管理系统
栏 目:
 
您的位置:首页 > 技术文档 > ASP编程
列出指定目录下的所有文件和目录
作者: 发布时间:2005-03-12 来源:
<%@ LANGUAGE = VBScript %>
<%Server.ScriptTimeout=5000%>
<html>

<head>
<style TYPE="text/css">
          /* Outline Style Sheet */
          UL UL {display: none;
                 margin-left: 20pt}
      </style>
<script LANGUAGE="JavaScript">
         function checkParent(src, dest) {
           // Search for a specific parent of the current element
           while (src!=null) {
             if (src.tagName == dest) return src;
             src = src.parentElement;
           }
           return null;
        }
        function outline() {     
           // Expand or collapse if a list item is clicked.
           var open = event.srcElement;
           // Make sure clicked inside an LI. This test allows rich HTML inside lists.
           var el = checkParent(open, "LI");
           if (null!=el) {
             var pos = 0;
             // Search for a nested list
             for (var pos=0; pos<el.children.length; pos++) {
               if ("UL"==el.children[pos].tagName) break;
            }
            if (pos==el.children.length) return;
          } else return;
          el = el.children[pos];
          if ("UL"==el.tagName) {
            // Expand or Collapse nested list
            if (""==el.style.display) {
              el.style.display = "block";
              el.style.listStyleImage = "url(images/folder.gif)";
              el.parentElement.style.listStyleImage = "url(images/ofolder.gif)";
            }
          else
          {
              el.style.display = "";
              el.parentElement.style.listStyleImage = "url(images/folder.gif)";
          }
        }
          event.cancelBubble = true;
        }
        document.onclick = outline;
       </script>

<base target="main">
<title>Folders</title>
<link rel="stylesheet" type="text/css" href="ase.css">
</head>

<body topmargin="0" leftmargin="0">

<SCRIPT LANGUAGE=vbscript RUNAT = Server>
    Dim fs, folderpara, folderArray    
    Set fs = CreateObject("Scripting.FileSystemObject")
if not isempty(request("txtRelative")) then
folderpara=server.mappath(request("txtRelative"))
else
folderpara=request("txtAbsolute")
end if
    Response.write "<UL>"
    Response.write "<LI STYLE='list-style-image: url(images/folder.gif)'><a href='files.asp?sPath=" &
folderpara & "'>" & folderpara & "</a></LI>"
    Call ShowFolderList(folderpara)
    Response.write "</UL>"
    set fs = Nothing

Sub ShowFolderList(folderspec)
    Dim f, f1, fc, s,fs
    Set fs=Server.CreateObject("Scripting.FileSystemObject")
    Set f = fs.GetFolder(folderspec)
    Set fc = f.SubFolders
    Set fs=f.Files
    'if (not (fc.count = 0)) then
       Response.write "<UL>"
       For Each f1 in fc
       s = f1.name
       If (not ((left (s, 1)) = "_")) then
        Response.write "<li>"
        Response.write "<a href='files.asp?sPath=" & f1 & "'>"
        Response.write s & "</LI>"
        Response.write "</a>"
        Call ShowFolderList((folderspec & "/" & s))
       end if
       Next
       
       For Each f1 in fs
       s = f1.name
       If (not ((left (s, 1)) = "_")) then
        Response.write "<li>"
        Response.write "<a href='files.asp?sPath=" & f1 & "'><font color=666666>"
        if instr(s,"product")>0 then
         Response.write replace(s,"product","<font color=008800>product</font>")
        else
         if instr(s,"prod")>0 then
         Response.write replace(s,"prod","<font color=008800>prod</font>")
         else
         Response.write s
         end if
        end if
        Response.write "</font></LI>"
        Response.write "</a>"
       end if
       Next
       Response.write "</UL>"
    'end if
end sub
</SCRIPT>

</body>
</html>
  
评论】【加入收藏夹】【 】【打印】【关闭
※ 相关链接
 ·在ASP中列出数据库中的表名和字段  (2005-03-12)
 ·asp列出sql数据库中(PUBS数据库)  (2005-03-12)
 ·asp列出sql数据库中所有数据视图  (2005-03-12)
 ·根据选择的Checkbox动态在表格中  (2005-03-12)

   栏目导行
  PHP编程
  ASP编程
  ASP.NET编程
  JAVA编程
   站点最新
·致合作伙伴的欢迎信
·媒体报道
·帝国软件合作伙伴计划协议
·DiscuzX2.5会员整合通行证发布
·帝国CMS 7.0版本功能建议收集
·帝国网站管理系统2012年授权购买说
·PHPWind8.7会员整合通行证发布
·[官方插件]帝国CMS-访问统计插件
·[官方插件]帝国CMS-sitemap插件
·[官方插件]帝国CMS内容页评论AJAX分
   类别最新
·在ASP中使用数据库
·使用ASP脚本技术
·通过启动脚本来感受ASP的力量
·学习使用ASP对象和组件
·解析asp的脚本语言
·初看ASP-针对初学者
·ASP开发10条经验总结
·ASP之对象总结
·ASP与数据库应用(给初学者)
·关于学习ASP和编程的28个观点
 
关于帝国 | 广告服务 | 联系我们 | 程序开发 | 网站地图 | 留言板 帝国网站管理系统