asp获取指定文件夹下面的所有文件信息
|
admin
2010年6月27日 17:27
本文热度 6367
|
[align=left]
<%
option explicit
dim infopath '当前路径
dim serverpath '服务器路径
dim objfso '文件组件
dim objfile '文件
dim objfolder '目录
dim objfoldercontents '所有文件
dim objfoldercount '临时数组变量-文件夹
dim objfileitem '临时数组变量-文件
dim fsize
function file_size(filesize)
select case true
case filesize<1024
fsize=filesize&" b"
case filesize<1048576
fsize=round((filesize/1024),0)&" kb"
case filesize<1073741824
fsize=round((filesize/1024/1024),0)&" mb"
case else
fsize=round((filesize/1024/1024/1024),0)&" gb"
end select
file_size=fsize
end function
set objfso=createobject("scripting.filesystemobject") '实例文件组件
set objfile=objfso.getfile("e:\wwwroot\file\table.asp") '读取文件所在路径
set objfolder=objfile.parentfolder '根据文件所在路径得到上级目录
set objfoldercontents=objfolder.files '所有文件付给数组
response.write "
"
response.write "文件名 | "
response.write "文件属性 | "
response.write "文件大小 | "
response.write "更新日期 |
"
for each objfoldercount in objfolder.subfolders '循环显示文件夹
response.write "
"&objfoldercount.name&" | " '文件夹名称
response.write ""&objfoldercount.type&" | " '文件夹属性
response.write " | "
'文件夹大小
response.write "
"&objfoldercount.datecreated&" | " '时间
next
for each objfileitem in objfoldercontents '循环
response.write "
"&objfileitem.name&" | "
'文件名
response.write "
"&objfileitem.type&" | " '类型
response.write ""&file_size(objfileitem.size)&" | " '文件大小
response.write ""&objfileitem.datelastmodified&" |
" '更新日期
next
response.write "
"
%>[/align]
该文章在 2010/6/27 17:27:08 编辑过