<% Set FSO=Server CreateObject("Scripting FileSystemObject") Set ServerFolder=FSO GetFolder(Server MapPath("photo")) Set ServerFolderList=ServerFolder Files For Each ServerFileEvery IN ServerFolderList %> <% =ServerFileEvery Name %> <% Next %>
lishixinzhi/Article/program/net/201311/14033<style type="text/css">
.filelist{ clear:both}
.filelist ul li{list-style:nonefloat:leftwidth:200px}
</style>
<%
response.Write("<div class='filelist'><ul><li>文件夹或文件</li><li>文件大小</li><li>最后修改时间</li></ul></div>")
filepath="文件夹相对路径"
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set fileobj = fso.GetFolder(server.mappath(filepath))
Set fsofolders = fileobj.SubFolders
Set fsofile = fileobj.Files
For Each folder in fsofolders
response.Write("<div class='filelist'><ul><li>"&folder.name&"</li><li>"&folder.size&"</li><li>"&folder.datelastmodified&"</li></ul></div>")
Next
For Each file in fsofile
response.Write("<div class='filelist'><ul><li>"&file.name&"</li><li>"&file.size&"</li><li>"&file.datelastmodified&"</li></ul></div>")
Next
%>
使用fso对象,可以列出所有文件和文件夹.以下的程序是我自己学ASP时写的,除了这个文件外,还有of,ol两个文件分别是来处理文件夹和文件.你可以参考一下.<%str="D:\"Set fs = CreateObject("Scripting.FileSystemObject")
set folder=fs.getfolder(str)
set folders=folder.SubFolders
for each item in folders%><a href="ol.asp?a=<%=server.URLEncode(str&item.name)&"\"%>"><%=item.name%></a><BR><%next%><BR><BR>以下是文件:<BR><%for each item in files%><a href="of.asp?b=<%=server.URLEncode(str&item.name)%>"><%=item.name%></a><BR><%next%>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)