热门文章
 
fso操作文件 实例函数
利用FSO取得BMP,JPG
FileSystemObje
fso使用:drive 读取
fso:folder 文件系
fso:file 文件对象
scripting.Text
ASP实现结构化列举并查看某
Adodb.Stream
ASP 批量文件改名
 推荐文章
 
asp无组件读取图片文件信息
限制(禁用)FSO组件的方法
fso使用例子:创建文件夹
fso:file 文件对象
fso应用中的几个小函数
ASP FSO相关的一些例子
fso的一些特殊功能
FSO读取网站系统使用空间的
使用FSO修改文件夹的名称
fso复制文件夹所有内容和删
FSO操作文件系统代码
稻香老农的无组件上传类(完整
一个基于Jscript和fs
无惧 无组件上传完整代码
asp静态模版技术之标签参数
无组件上传文件被杀毒软件误报
 
你现在的位置:您现在的位置是: 中国ASP>>ASP教程>>fso组件
ASP实现结构化列举并查看某路径下所有文件

<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">
<</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)    
  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>

相关信息:

fso操作文件 实例函数
利用FSO取得BMP,JPG,PNG,GIF文件信息
FileSystemObject对象成员概要
fso使用:drive 读取驱动器信息
fso:folder 文件系统
fso:file 文件对象
scripting.TextStream对象-fso读写文本
ASP实现结构化列举并查看某路径下所有文件

 

中国ASP技术 ASP.ORG.CN 版权所有 2004-2008