我要用ASP做一个网站的管理系统,需要获取服务器某目录下所有文件的信息,如文件名、大小等,ASP有没有办法解决?
---------------------------------------------------------------
dim fso, f, fc
dim fp ' 文件路径
fp = request("fp")
if trim(fp) = "" then fp = "C:"
set fso = server.createobject("scripting.filesystemobject")
set f = fso.getFolder(fp)
set fc = f.subFolders
response.write "
1<b>类型 名称 大小</b>
1<br/>
"
for each ff in fc
response.write "文件夹 "
response.write "
1<a ""="" f.asp?fp=" & ff.path & " href="">" & ff.name & "</a>
"
.write ff.size & "
1<br/>
"
next
set fc = f.files
for each ff in fc
response.write "文件 "
response.write ff.name & " "
response.write ff.size & "
1<br/>
"
next
---------------------------------------------------------------
1<table border="">
2<tr>
3<td>
4Attributes 属性</td><td> DateCreated 属性</td><td> DateLastAccessed 属性</td><td> DateLastModified 属性</td><td> Drive 属性</td><td> Name 属性</td><td> ParentFolder 属性</td><td> Path 属性</td><td> ShortName 属性</td><td> ShortPath 属性</td><td> Size 属性</td><td> Type 属性<td>
5<tr>
6
Function ShowFolderList(folderspec)
Dim fso, f, f1, fc, s
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(folderspec)
Set fc = f.Files
For Each f1 in fc
s = s & "<tr><td>" & f1.Attributes & "</td><td>" & f1.DateCreated & "</td><td>" & f1.DateLastAccessed & "</td><td>" & f1.DateLastModified & "</td><td>" & f1.Drive & "</td><td>" & f1.Name & "</td><td>" & f1.ParentFolder & "</td><td>" & f1.Path & "</td><td>" & f1.ShortName &"</td><td>" & f1.ShortPath & "</td><td>" & f1.Size & "</td><td>" & f1.Type & "<td></td></td></tr>"
Next
ShowFolderList = s
End Function
Response.write ShowFolderList("D:\asptest")
1</tr></td></td></tr></table>