铁雪资源网 Design By www.gsvan.com

核心代码

'----------------------
'获得文件夹的大小
'Author  = baiyang
'Version = 1.0
'Date  = 09.08.08
'----------------------
Option Explicit
On Error Resume Next
Dim objFSO, objLocalFolder, strArg, longLocalFolderSize, strSizeMess
'判断是不是没有路径参数
If WScript.Arguments.Count < 1 Then
  WScript.Echo "参数无效, 第一个参数为路径"
  WScript.Quit
Else
  strArg = WScript.Arguments(0)
End If

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objLocalFolder = objFSO.GetFolder(strArg)

If objLocalFolder = Empty Then
  WScript.Echo "Invalid Path"
  WScript.Quit
End If

longLocalFolderSize = objLocalFolder.Size

If longLocalFolderSize>=1024 And longLocalFolderSize<1024*1024 Then
  strSizeMess = Round( longLocalFolderSize/1024, 3 ) & " K"
  ElseIf longLocalFolderSize>=1024*1024 And longLocalFolderSize<1024*1024*1024 Then
  strSizeMess = Round( longLocalFolderSize/1024/1024, 3 ) & " M"
  ElseIf longLocalFolderSize>=1024*1024*1024 Then
   strSizeMess = Round( longLocalFolderSize/1024/1024/1024, 3 ) & " G"
   Else
   strSizeMess = longLocalFolderSize & " B"
End If

WScript.Echo strSizeMess
Set objFSO = Nothing
Set objLocalFolder = Nothing
WScript.Quit

使用方法:

将上面的挨骂保存文件为: GetFloderSize.vbs
用法: GetFloderSize.vbs C:\windows即可。

标签:
VBS,文件夹大小

铁雪资源网 Design By www.gsvan.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
铁雪资源网 Design By www.gsvan.com

评论“获得文件夹大小的VBS代码”

暂无获得文件夹大小的VBS代码的评论...