订阅本栏目 RSS您所在的位置: 深山工作室 > ASP > 正文

asp利用FSO检测服务器空间文件夹大小

深山行者个人网站 2009/8/17 9:00:37 深山行者 字体: 浏览 8612

asp利用FSO检测服务器空间文件夹大小

<style type="text/css">
* {margin:0;padding:0;font-size:12px;}
body {padding:15px;}
.size1 {font-weight:bold;color:#f00;}
.size2 {font-weight:bold;color:#00f;}
</style>

<%
Sub ShowSpaceInfo(drvpath)
 dim fso,d,size,showsize
 set fso=server.createobject("scripting.filesystemobject")
 drvpath=server.mappath(drvpath)
 set d=fso.getfolder(drvpath)
 size=d.size
 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 "<span class='size1'>" & showsize & "</span>"
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 & "&nbsp;Byte"
 if size>1024 then
    size=(size\1024)
    showsize=size & "&nbsp;KB"
 end if
 if size>1024 then
    size=(size/1024)
    showsize=formatnumber(size,2) & "&nbsp;MB"
 end if
 if size>1024 then
    size=(size/1024)
    showsize=formatnumber(size,2) & "&nbsp;GB"
 end if  
 response.write "<span class='size2'>" & showsize & "</span>"
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
%>

系统空间的使用情况<br>

<%
fsoflag=1
if fsoflag=1 then

    Function GetPP
    dim s
    s=Request.ServerVariables("path_translated")
    GetPP=left(s,instrrev(s,"\",len(s)))
    End function
    if sPP="" then sPP=GetPP
    if right(sPP,1)<>"\" then sPP=sPP&"\"
    set fso=server.createobject("scripting.filesystemobject")
    Set f = fso.GetFolder(sPP)
    Set fc = f.SubFolders
    i=1
                        i2=1
    For Each f in fc
%>

目录<b><%=f.name%></b>占用空间:

<div class="sizediv" style="width:<%=drawbar(""&f.name&"")%>px;"></div><%showSpaceinfo(""&f.name&"")%><br>

<%
    i=i+1
    if i2<10 then
    i2=i2+1
    else
    i2=1
    end if
    Next
%>
程序文件占用空间:
<div class="sizediv" style="width:<%=drawspecialbar%>px;"></div><%showSpecialSpaceinfo("Program")%><br>

系统占用空间总计:
<div class="sizediv" style="width:400px;"></div><%showspecialspaceinfo("All")%>

<%
    else
    response.write "本功能已经被关闭"
    end if
%>

<style>
.sizediv {height:10px;background:#91d65c;border-left:solid 2px #91d65c;}
</style>

相关阅读
div+CSS的无限级扩展下拉菜单(全部加了注释)
asp中求两个数的百分比(利用百分比函数FormatPercent就可以自带%的符号)
区分IE6,IE7和firefox的CSS hack
asp金额数字转换为大小写汉字
javascript正则的用法与示例
另外一种符合web2.0的链接打开方式--利用base打开链接
CSS编写过程中常见的10个错误以及解决方法
[转载]中国行政区划数据(省市区街道)
共有0条关于《asp利用FSO检测服务器空间文件夹大小》的评论
发表评论
正在加载评论......
返回顶部发表评论
呢 称:
表 情:
内 容:
评论内容:不能超过 1000 字,需审核,请自觉遵守互联网相关政策法规。
验证码: 验证码 
网友评论声明,请自觉遵守互联网相关政策法规。

您发布的评论即表示同意遵守以下条款:
一、不得利用本站危害国家安全、泄露国家秘密,不得侵犯国家、社会、集体和公民的合法权益;
二、不得发布国家法律、法规明令禁止的内容;互相尊重,对自己在本站的言论和行为负责;
三、本站对您所发布内容拥有处置权。

更多信息>>栏目类别选择
百度小程序开发
微信小程序开发
微信公众号开发
uni-app
asp函数库
ASP
DIV+CSS
HTML
python
更多>>同类信息
ASP中Utf-8与Gb2312编码转换乱码问题的解决方法页面编码声明
asp显示随机密码
通过阿里云服务接口获得ip地址详细信息
iis点开后任务栏上有显示,但是窗口看不到的解决办法
RSA加密解密插件
微软Encoder加密解密函数
更多>>最新添加文章
python通过代码修改pip下载源让下载库飞起
python里面requests.post返回的res.text还有其它的吗
aliyun阿里云续费域名优惠口令(注册、续费都可以使用)
windows7环境下安装配置jdk
python对微信操作要用到这两个库wxpy与itchat
ASP中Utf-8与Gb2312编码转换乱码问题的解决方法页面编码声明
DW设置之后更好用 DreamweaverCS编辑GB2312与UTF-8文件在代码视图中点击鼠标错位问题的解决办法
解决国内 github.com 打不开的准确方法
更多>>随机抽取信息
旅行社手机网站模板9
ASP汉字图片验证码
ASP 格式化显示时间为几个月,几天前,几小时前,几分钟前,或几秒前
超级实用且不花哨的js代码大全( 2 )
浅谈 Vista系统设置IIS7攻略
另类营销,“我在床上很厉害的哦”引发的思考