海外邮件中继,海外退信中继,美国高速VPS,不限流量VPN,邮局维护和管理,邮件网关,EMOS邮件中继,POSTFIX邮件中继,Winwebmail邮件中继,Winmail邮件中继,DBMail邮件中继,JDMail邮件中继,Exchange邮件中继,MDaemon邮件中继 淘宝店:http://shantan.taobao.com 云邮科技官网:www.yunrelay.com
【字体设置:大 中 小】
<%@ LANGUAGE="VBScript" %>
<html>
<head>
<title>使用ASP遍历并列表显示目录文件</title>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312" />
<link rel="stylesheet" type="text/css" href="default.css" />
</head>
<body>
<div id="demoBox">
<h3>演示:使用ASP遍历并列表显示目录文件</h3>
<p>下面列表显示了本站根目录下的三个独立的目录文件夹('page','log','about'),并递归显示这些文件夹下的所有子文件夹和文件信息。另外,所有文件都带有链接信息。</p>
</div>
<!-- List these three folders. -->
<ul>
<% ListFolderContents(Server.MapPath("/page")) %>
<% ListFolderContents(Server.MapPath("/log")) %>
<% ListFolderContents(Server.MapPath("/about")) %>
</ul>
</body>
</html>
<% sub ListFolderContents(path)
dim fs, folder, file, item, url
set fs = CreateObject("Scripting.FileSystemObject")
set folder = fs.GetFolder(path)
'显示目标文件夹和相关信息
Response.Write("<li><b>" & folder.Name & "</b> - " _
& folder.Files.Count & " 个文件,")
if folder.SubFolders.Count > 0 then
Response.Write(folder.SubFolders.Count & " 个子文件夹,")
end if
Response.Write(Round(folder.Size / 1024) & " KB 大小" _
& vbCrLf)
Response.Write("<ul>" & vbCrLf)
'显示所有子文件夹列表
for each item in folder.SubFolders
ListFolderContents(item.Path)
next
'显示所有文件列表
for each item in folder.Files
url = MapURL(item.path)
Response.Write("<li><a href=""" & url & """>" & item.Name & "</a> - " _
& item.Size & " bytes " _
& "最后修改时间:" & item.DateLastModified & "." _
& "</li>" & vbCrLf)
next
Response.Write("</ul>" & vbCrLf)
Response.Write("</li>" & vbCrLf)
end sub
function MapURL(path)
dim rootPath, url
'物理路径转换回URL路径(超级链接)
rootPath = Server.MapPath("/")
url = Right(path, Len(path) - Len(rootPath))
MapURL = Replace(url, "\", "/")
end function %>
发表评论 - 不要忘了输入验证码哦!