这是一个非常酷的页面。我将它用于我的测试站点。
有很多 ASP 页面?
讨厌手动更新链接?
让这个页面为您完成工作!
<%
showdirs=1
Function ShowImageForType(strName)
Dim strTemp
strTemp = strName
If strTemp <> "dir" Then
strTemp = LCase(Right(strTemp, Len(strTemp) - InStrRev(strTemp, ".", -1, 1)))
End If
Select Case strTemp
Case "asp"
strTemp = "asp"
Case "dir"
strTemp = "dir"
Case "htm", "html"
strTemp = "htm"
Case "gif", "jpg"
strTemp = "img"
Case "txt"
strTemp = "txt"
Case Else
strTemp = "misc"
End Select
strTemp = "<IMG SRC=""/images/dir_" & strTemp & ".gif"" WIDTH=16 HEIGHT=16 BORDER=0>"
ShowImageForType = strTemp
End Function
'That's it for functions on this one!
%>
<%' Now to the Runtime code:
Dim strPath 'Path of directory to show
Dim objFSO 'FileSystemObject variable
Dim objFolder 'Folder variable
Dim objItem 'Variable used to loop through the contents of the folder
strPath = "./"
requestedPath = request.querystring("path")
if requestedPath <> "" then strPath = requestedPath
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(Server.MapPath(strPath))
%>
<html><head>
<link rel="stylesheet" type="text/css" href="/include/kb1.css">
</head>
Contents of <B><%= strPath %></B><BR>
<BR>
<TABLE BORDER="5" BORDERCOLOR="green" CELLSPACING="0" CELLPADDING="2">
<TR BGCOLOR="#006600">
<TD><FONT COLOR="#FFFFFF"><B>File Name:</B></FONT></TD>
<TD><FONT COLOR="#FFFFFF"><B>File Size (bytes):</B></FONT></TD>
<TD><FONT COLOR="#FFFFFF"><B>Date Created:</B></FONT></TD>
<TD><FONT COLOR="#FFFFFF"><B>File Type:</B></FONT></TD>
</TR>
<%
if showdirs=1 then
For Each objItem In objFolder.SubFolders
' Deal with the stupid VTI's that keep giving our visitors 404's
If InStr(1, objItem, "_vti", 1) = 0 Then
%>
<TR BGCOLOR="#CCFFCC">
<TD ALIGN="left" ><%= ShowImageForType("dir") %> <A HREF="<%= strPath & objItem.Name %>"><%= objItem.Name %></A></TD>
<TD ALIGN="right">N/A</TD>
<TD ALIGN="left" ><%= objItem.DateCreated %></TD>
<TD ALIGN="left" ><%= objItem.Type %></TD>
</TR>
<%
End If
Next 'objItem
End If ' showdirs
For Each objItem In objFolder.Files
%>
<TR BGCOLOR="#CCFFCC">
<TD ALIGN="left" ><%= response.write(" ") %> <A HREF="<%= strPath & objItem.Name %>"><%= objItem.Name %></A></TD>
<TD ALIGN="right"><%= objItem.Size %></TD>
<TD ALIGN="left" ><%= objItem.DateCreated %></TD>
<TD ALIGN="left" ><%= objItem.Type %></TD>
</TR>
<%
Next 'objItem
Set objItem = Nothing
Set objFolder = Nothing
Set objFSO = Nothing
%>
</TABLE>
</html>