找回密码
 加入
搜索
查看: 1593|回复: 2

有没有比这更好的获取指定目录的大小?

[复制链接]
发表于 2008-9-17 22:12:27 | 显示全部楼层 |阅读模式
函数中只有获取文件大小,分区大小,但无法得到目录大小,谁能获取?

下面我自己搞了个,但有没有比这更简洁的?
Dim $s
_filelist("C:\WINDOWS\$hf_mig$")
MsgBox(0, "大小,MB", $s / 1048576)
Func _filelist($DirSource)

        If FileExists($DirSource) = 0 Then
                MsgBox(64, "提示", "【" & $DirSource & "】目录不存在!请重新指定有效目录.")
        Else
                Local $WorkingDir, $search, $file
                FileChangeDir($DirSource)
                $search = FileFindFirstFile("*.*")
                If $search = -1 Then
                        ;MsgBox(64, "完成提示", "在目录【" & $DirSource & "】下未找到任何文件和子目录!")
                Else
                        While 1
                                $file = FileFindNextFile($search)
                                If @error Then ExitLoop
                                If StringInStr(FileGetAttrib($DirSource & "" & $file), "D") Then
                                        _filelist($DirSource & "" & $file)
                                Else
                                        ;MsgBox(0, 000, $DirSource & "" & $file)
                                        ;If StringRight($file, 3) = "exe" Then
                                        ; FileWriteLine(@ScriptDir & "\file.txt", $DirSource & "" & $file & @CRLF)
                                        ;EndIf
                                        $s += FileGetSize($DirSource & "" & $file)

                                EndIf
                        WEnd
                EndIf
        EndIf
EndFunc   ;==>_filelist
[ 本帖最后由 itljl 于 2008-9-18 04:15 编辑 ]
 楼主| 发表于 2008-9-18 04:15:29 | 显示全部楼层
半夜起来又看了一遍..DirGetSize( "目标路径" [, 标志] )
发表于 2009-11-20 05:20:42 | 显示全部楼层
呵呵,不错,学习了~
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-6-16 08:45 , Processed in 0.071852 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表