以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 如何查看文件夹大小? (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=189116) |
-- 作者:ygg8310 -- 发布时间:2023/11/10 18:52:00 -- 如何查看文件夹大小? For
Each dir As
String
In
FileSys.GetDirectories("C:\\") 有没有办法获取dir的大小? |
-- 作者:linyunu -- 发布时间:2023/11/10 20:16:00 -- 使用 TotalSize = 0 \'重置计数 Dim TheSize As Long = GetDirSize("D:\\Publish") Output.Show(TheSize/1024/1024) 全局代码 Public TotalSize As Long Public Function GetDirSize(RootFolder As String) As Long
Dim FolderInfo = New IO.DirectoryInfo(RootFolder)
For Each File As IO.FileInfo In FolderInfo.GetFiles : TotalSize += File.Length
Next
For Each SubFolderInfo As IO.DirectoryInfo In FolderInfo.GetDirectories : GetDirSize(SubFolderInfo.FullName)
Next
Return TotalSize End Function [此贴子已经被作者于2023/11/11 12:39:12编辑过]
|