<%
Sub ListFolderContents(Path)
Dim fs, Folder, File, Item, url
Set fs = CreateObject("Scripting.FileSystemObject")
Set Folder = fs.GetFolder(Path)
'Display the target folder and info.
Response.Write("" & Folder.Name & " - " & Folder.Files.Count & " files, ")
If Folder.SubFolders.Count > 0 Then
Response.Write(Folder.SubFolders.Count & " directories, ")
End If
Response.Write(Round(Folder.Size / 1024) & " KB total." & vbCrLf)
Response.Write("& vbCrLf)
'Display a list of sub folders.
For Each Item in Folder.SubFolders
ListFolderContents(Item.Path)
Next
'Display a list of files.
For Each Item in Folder.Files
url = MapURL(Item.Path)
Response.Write("& url & """>" & Item.Name & " - " & Item.Size & " bytes, " & "last modified on " & Item.DateLastModified & "." & "" & vbCrLf)
Next
Response.Write("" & vbCrLf)
Response.Write("" & vbCrLf)
End Sub
Function MapURL(Path)
Dim rootPath, url
'Convert a physical file path to a URL for hypertext links.
rootPath = Server.MapPath("/")
url = Right(Path, Len(Path) - Len(rootPath))
MapURL = Replace(url, "\", "/")
End Function
ListFolderContents(server.mappath("/"))
%>
本文作者:柳永法 来源:http://www.yongfa365.com/
CIO之家 www.ciozj.com 微信公众号:imciow