ASP利用fso列出网站文件占用代码

列出网站有哪些主文件夹,分别占用多少空间

<%
function ObjSize(fsize,str)
select case str
case “m”
objsize = formatnumber(fsize/1024/1024,2)
case “k”
objsize = formatnumber(fsize/1024,2)
case else
objsize = 0.00
end select
if objsize >= 0 and objsize < 1 then objsize = “0”&objsize
end function
%>

<%
Set fso = Server.CreateObject(“Scripting.FileSystemObject”)
%>
<table width=”600″ cellspacing=”1″ cellpadding=”3″>
<tr valign=”top”>
<td align=”center”><fieldset><legend>空间统计</legend><table width=”98%” cellpadding=”1″ cellspacing=”1″ bgcolor=”#F5F5F5″>
<tr valign=”top” bgcolor=”#FFFFFF”>
<td width=”30%”><%
Set objFolder = fso.GetFolder(Server.MapPath(“../”))
sumsize = 0
For Each objItem In objFolder.SubFolders
%>
<img src=”images/style/16×16/Folder.gif” width=”16″ height=”16″ hspace=”6″ align=”absmiddle”><%= objItem.Name %></td>
<td width=”30%” align=”right”><%= ObjSize(objItem.Size,”k”) %> KB </td>
<td width=”40%” style=”padding-left:30px; “><%=objItem.datecreated %></td>
</tr>
<tr valign=”top” bgcolor=”#FFFFFF”>
<td><%
sumsize = sumsize + objItem.Size
Next
set objItem = nothing
set objobjFolder = nothing
sumsize1 = sumsize
sumsize_mb = objsize(sumsize1,”m”)
sumsize_kb = objsize(sumsize1,”k”)
%>
<img src=”images/style/16×16/Folder%20(Add).gif” width=”16″ height=”16″ hspace=”6″ align=”absmiddle”><b style=”color:#FF0000; “>总占用空间:&nbsp;</b></td>
<td align=”right”><b style=”color:#FF0000; “><%= sumsize_kb %> KB </b></td>
<td align=”left”>&nbsp;&nbsp;<b style=”color:#FF0000; “>= <%= sumsize_mb %> MB </b></td>
</tr>
</table></fieldset>

原文链接:,转发请注明来源落伍老站长!

发表评论