动网论坛,站长建站首选,国内使用量最多的论坛软件 动网论坛官方技术讨论区 站长工具 申请属于您自己的免费论坛
首页 | 新闻资讯 | 网站运营 | 网络编程 | 数据库 | 服务器 | 网页设计 | 图像媒体 | 网络应用 | 搜索优化 | 资源下载 | 动网主机 | DVBOX
    本站内  互联网 ASP论坛  ASP.Net论坛  PHP论坛
   Asp → 阅读文章

 ASP实现结构化列举并查看某路径下所有文件

作者:同济黄正 来源:CSDN 
阅读 1749 人次 , 2006-2-15 14:12:00 

<style 此样式表须保留>
<!--
   u.{background-color:FEDC76;cursor:hand;}
   a{background-color:97EF53;}
   font{padding-bottom:0;padding-top:0;margin-bottom:0;margin-top:0;}
-->
</style>
<title>本站文件地图</title>
<body>
<span id=shhi style="text-align:right;width:20%;position:absolute;bottom:0">
<a href=# onclick=’jscript:if(rightf.style.display=="")rightf.style.display="none";else rightf.style.display="";return false’ style=background-color:red>Hide/Show =></a>
</span>
<div id=rightf style="height:100%;width:80%;position:absolute;right:0;top:0">
<iframe align=right name="right" scrolling=auto style="height:100%;width:100%;" src="about:blank"> </iframe>
</div>
<base target="right">

<Script language=VBScript>
<!--
Sub window_onscroll()
   rightf.style.pixelTop=document.body.scrollTop
   shhi.style.top=document.body.clientHeight+document.body.scrollTop-30
End Sub
sub DoFold(index)   ’显示与隐藏某节点的过程
   dim itm
   set itm=eval("divfold" & index)
   if itm.style.display="none" then
      itm.style.display=""
   else
      itm.style.display="none"
   end if
   set itm = document.all(itm.sourceIndex-2)
   if itm.innerText="0" then
      itm.innerText="1"
   else
      itm.innerText="0"
   end if
   set itm=document.all("itmjj" & index)
   if not itm is nothing then
        if itm.innerText="+" then
         itm.innerText="-"
      else
         itm.innerText="+"
      end if
   end if
end sub
-->
</Script>



<%
’------ASP程序段--------------------------------------
set Fso=Server.CreateObject("Scripting.FileSystemObject")   ’服务器须支持FSO
   dim path,mappath
   if request("path")="" then
      path="" ’须先设置好想要查看的文件夹的名称,即path=路径名称,例如要查看 http://websamba.com/hzhzhz/ 时,设置path="hzhzhz"
   else
      path=request("path")    ’可以如此设置:<a href="dirpath.asp?path=hzhzhz">..
   end if
   mappath=Server.MapPath("/" & path)
if Fso.folderexists(mappath)=false then
   response.write "路径:http://" & Request.ServerVariables("HTTP_HOST") & "/" & path & "不存在!"
   response.end
end if
dim Tf
tf=0
Sub DirThisFolder(Fo,strHead)    ’递归过程,程序作者: 同济黄正 http://websamba.com/hzhzhz/
   if not fso.FolderExists(Fo) then exit sub
   dim foN,fiN,Tt
   Set Folde = Fso.GetFolder(Fo)
   foN=Folde.SubFolders.count
   fiN=Folde.files.count
   
   Tt="<u lab=""包含" & foN & "个子文件夹," & fiN & "个子文件"" onclick=Dofold(" & tf & ")>"
   if foN then Tt=tt & "<q id=itmjj" & tf & ">+</q>"
   tt=tt & "<font face=Wingdings>0</font>"    ’类似图标的字符
   if len(strHead) then
      if fiN>0 then
         Response.Write left(strHead,len(strHead)-1) & "├" & Tt & Folde.name & "</u><br>"
      else
         Response.Write left(strHead,len(strHead)-1) & "├" & Tt & Folde.name & "</u><br>"
      end if
   else
      Response.Write "" & Tt & Folde.path & "</u><br>"
   end if
   
   
   Response.Write "<span id=divfold" & tf & " style=""display:none"">"
   tf=tf +1
   If foN  Then
      i=0
         For Each Fol In Folde.SubFolders
            isLastFol=(i=foN-1)
            if fiN > 0 then
               DirThisFolder Fol.Path,strHead & "│"    ’递归子文件夹
            else
               DirThisFolder Fol.Path,strHead & "└"
            end if
            i=i+1
         Next
   End If
   
   If fiN > 0 Then
      i=0
         For Each Fi In Folde.files
         ’For i=0 to fiN-1
            if i=fiN-1 then
               Response.Write  strHead & "└"
            else   
               Response.Write  strHead & "├"
            end if
            Response.Write "<a lab=""" & fi.size & "B  " & fi.DateLastModified & """ href=""http://" & Request.ServerVariables("HTTP_HOST") & "/" & path & replace(fi.path,mappath,"",1) & """><font face=Wingdings>m</font>" & fso.GetFileName(fi.name) & "</a><br>"
            i=i+1
         Next
   End If
   Response.Write "</span>"
End Sub
DirThisFolder mappath,""
%>
<Script language=VBScript>
<!--
DoFold 0
-->
</Script>

  
 
 收藏本文  打印本文  论坛讨论  关闭窗口
· 上一篇:不用Golobal和session实现在线人数统计
· 下一篇:常用Response对象的使用祥解
· 如何更好更快的debug
· 服务器端组件的最小需求是什么?我能够使用已经存在的Automation servers吗
· 使用ASP实现http://xx@xx.xx虚拟域名
· ASP之80004005错误信息的解析
· 邮件服务器端软件-IMAIL基础教程


关于本站 | 联系我们 | 业务合作 | 客户案例 | 诚聘英才 | 广告合作 | 收藏本站
海口动网先锋网络科技有限公司版权所有
Copyright © 2000 - 2006 Cndw.Com
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077