·您的位置: 首页 » 资源教程 » 编程开发 » ASP » ASP实现结构化列举并查看某路径下所有文件

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

类别: ASP教程  评论数:0 总得分:0
<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>
-= 资 源 教 程 =-
文 章 搜 索
关键词:
类型:
范围:
纯粹空间 softpure.com
Copyright © 2006-2008 暖阳制作 版权所有
QQ: 15242663 (拒绝闲聊)  Email: faisun@sina.com
 纯粹空间 - 韩国酷站|酷站欣赏|教程大全|资源下载|免费博客|美女壁纸|设计素材|技术论坛   Valid XHTML 1.0 Transitional
百度搜索 谷歌搜索 Alexa搜索 | 粤ICP备19116064号-1