Foxtable(狐表)用户栏目专家坐堂 → 如何查看文件夹大小?


  共有1757人关注过本帖树形打印复制链接

主题:如何查看文件夹大小?

帅哥哟,离线,有人找我吗?
linyunu
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:童狐 帖子:250 积分:1864 威望:0 精华:2 注册:2018/1/16 20:53:00
  发帖心情 Post By: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编辑过]

 回到顶部