【发布时间】:2015-05-05 06:39:47
【问题描述】:
我正在重新设计我们部门的网站,我们的 IT 部门不支持 Intranet 开发。该服务器运行 ASP Classic,并且能够在一定程度上运行 VB 脚本和 Javascript(有些工作其他人不能)。
所以这是我的问题:
我修改了一个从http://www.brainjar.com/asp/dirlist/ 得到的简单代码 列出目录中的所有 PDF 文件,包括子目录,但我不确定如何对其进行排序。
到目前为止,它会按其读取的每个文件夹的字母顺序对其进行排序。我希望它通过 item.DateLastModified 属性对每个子目录的每个文件进行排序,我不知道这是否可能。
我想我需要将项目存储在一个数组中,然后对数组进行排序并打印数据,但我不知道该怎么做,自从我参加编程课程以来已经 10 年了。
任何帮助将不胜感激!
我正在使用的当前代码:
====>
<% sub ListFolderContents(path)
dim fs, folder, file, item, url
set fs = CreateObject("Scripting.FileSystemObject")
set folder = fs.GetFolder(path)
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)
if item.type = "PDF File" then
Response.Write("<dt><a href=""" & url & """>" & item.Name & "</a>" _
& vbCrLf)
end if
next
Response.Write("</dt>" & 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 %>
【问题讨论】:
标签: sorting vbscript asp-classic file-management