上一篇:ASP中文本文件与数据库文件的数据交换(FSO) >>
列出指定目录下的所有文件和目录
<%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.NET程序中实现语音合成
- · 在Apache上调试ASP.NET 1.1/2.0代码
- · ASP.NET初学:建立ASP.NET开发平台
- · 用ASP.Net和Access编写留言本
- · .net中发mail到hotmail中乱码问题的解决
- · ASP.Net应用程序的多进程模型
- · 用 ASP.NET 2.0 改进的 ViewState 加快网站速度
- · 在ASP.NET中使用Session常见问题集锦
- · ASP.NET文章管理系统:系统分析与设计
- · asp.net开发常用技巧收集
- · ASP.NET 2.0运行时简要分析
- · 在IIS6.0下ASP .NET 的版本冲突问题
- · ASP.NET:目录的遍历
- · ASP.NET:目录创建和删除
- · ASP.Net:基于窗体的身份验证
- · 防刷新重复提交、防后退方法
- · ASP.NET程序实现博客日历
- · 掌握Web窗体的生命周期与状态管理
- · ASP.NET 移动 Web 窗体和 ASP.NET 兼容性
- · ASP.NET入门随想之多态、接口与委托
- · ASP.Net项目出错处理方法汇总
- · 利用ASP.NET程序来访问Excel文档
- · ASP.NET应用程序开发七大技巧
- · VB.NET开发人员必备参考10本书目
- · 用ADO.NET处理层次数据
- · ASP.NET实现在服务器端控制网页
- · 用ASP.NET向Javascript传递变量
- · ASP.NET实现抓取网页中的链接
- · 在ASP.NET 2.0中实现数据的绑定
- · ASP.NET随机显示数据库记录
- · ASP.Net生成业务数据的统计图形
- · 剖析ASP.NET2.0导航功能之控制地图信息
- · ASP.Net中利用CSS实现多界面的方法
- · ASP.NET 常见问题
- · 在ASP.NET中实现POST发送数据
- · ASP.NET页面导航方式之比较与选择
- · ASP.NET操作IIS中的虚拟目录
- · 在ASP.NET 2.0中实现本地化
