<html>
<body>读取一个文件相关信息的范例<br><br>
</body></html>
动网论坛的代码,你参考一下吧
<!--#include file =conn.asp-->
<!-- #include file="inc/const.asp" -->
<title><%=forum_info(0)%>--管理页面</title>
<!--#include file=inc/forum_css.asp-->
<meta name=generator content="microsoft frontpage 3.0" charset=gb2312>
<body <%=forum_body(11)%>>
1024 then
size=(size/1024)
showsize=size & kb
end if
if size>1024 then
size=(size/1024)
showsize=formatnumber(size,2) & mb
end if
if size>1024 then
size=(size/1024)
showsize=formatnumber(size,2) & gb
end if
response.write <font face=verdana> & showsize & </font>
end sub
sub showspecialspaceinfo(method)
dim fso,d,fc,f1,size,showsize,drvpath
set fso=server.createobject(scripting.filesystemobject)
drvpath=server.mappath(pic)
drvpath=left(drvpath,(instrrev(drvpath,/)-1))
set d=fso.getfolder(drvpath)
if method=all then
size=d.size
elseif method=program then
set fc=d.files
for each f1 in fc
size=size+f1.size
next
end if
showsize=size & byte
if size>1024 then
size=(size/1024)
showsize=size & kb
end if
if size>1024 then
size=(size/1024)
showsize=formatnumber(size,2) & mb
end if
if size>1024 then
size=(size/1024)
showsize=formatnumber(size,2) & gb
end if
response.write <font face=verdana> & showsize & </font>
end sub
function drawbar(drvpath)
dim fso,drvpathroot,d,size,totalsize,barsize
set fso=server.createobject(scripting.filesystemobject)
drvpathroot=server.mappath(pic)
drvpathroot=left(drvpathroot,(instrrev(drvpathroot,/)-1))
set d=fso.getfolder(drvpathroot)
totalsize=d.size
drvpath=server.mappath(drvpath)
set d=fso.getfolder(drvpath)
size=d.size
barsize=cint((size/totalsize)*400)
drawbar=barsize
end function
function drawspecialbar()
dim fso,drvpathroot,d,fc,f1,size,totalsize,barsize
set fso=server.createobject(scripting.filesystemobject)
drvpathroot=server.mappath(pic)
drvpathroot=left(drvpathroot,(instrrev(drvpathroot,/)-1))
set d=fso.getfolder(drvpathroot)
totalsize=d.size
set fc=d.files
for each f1 in fc
size=size+f1.size
next
barsize=cint((size/totalsize)*400)
drawspecialbar=barsize
end function
%>
<table align=center cellspacing=1 cellpadding=1 class=tableborder1>
<tr>
<th height=25> 系统空间占用情况</th> </th>
</tr>
<tr>
<td class=tablebody1>
<blockquote>
<%
fsoflag=1
if fsoflag=1 then
%>
<br>
法规数据占用空间: <img src="pic/bar1.gif" width=<%=drawbar("data")%> height=10> <%showspaceinfo("data")%><br><br>
备份数据占用空间: <img src="pic/bar1.gif" width=<%=drawbar("databackup")%> height=10> <%showspaceinfo("databackup")%><br><br>
程序文件占用空间: <img src="pic/bar1.gif" width=<%=drawspecialbar%> height=10> <%showspecialspaceinfo("program")%><br><br>
心情图片占用空间: <img src="pic/bar1.gif" width=<%=drawbar("images")%> height=10> <%showspaceinfo("face")%><br><br>
系统图片占用空间: <img src="pic/bar1.gif" width=<%=drawbar("pic")%> height=10> <%showspaceinfo("pic")%><br><br>
上传头像占用空间: <img src="pic/bar1.gif" width=<%=drawbar("uploadface")%> height=10> <%showspaceinfo("uploadface")%><br><br>
上传图片占用空间: <img src="pic/bar1.gif" width=<%=drawbar("uploadimages")%> height=10> <%showspaceinfo("uploadimages")%><br><br>
系统占用空间总计:<br><img src="pic/bar1.gif" width=400 height=10> <%showspecialspaceinfo("all")%>
</blockquote>
</td>
</tr>
</table>
asp--文件操作类 设计版
以上就是asp 对文件操作问题总结的详细内容。