BonJovi 2006-5-14 13:53
ASP的服务器端操作?
我要用ASP做一个网站的管理系统,需要获取服务器某目录下所有文件的信息,如文件名、大小等,ASP有没有办法解决?
月光飘影 2006-5-14 13:53
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 "<b>类型 名称 大小</b><br>"
for each ff in fc
response.write "文件夹 "
response.write "<a href=""f.asp?fp=" & ff.path & """>" & ff.name & "</a> "
.write ff.size & "<br>"
next
set fc = f.files
for each ff in fc
response.write "文件 "
response.write ff.name & " "
response.write ff.size & "<br>"
next
丢丢 2006-5-14 13:54
<table border>
<tr>
<td>
Attributes 属性</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>
<tr>
<%
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></tr>"
Next
ShowFolderList = s
End Function
Response.write ShowFolderList("D:\asptest")
%>
</table>