下面的函数用来计算某个文件目录所占的字节数:
REM 函数返回值为目录所占字节数
Function DirUsedBytes(ByVal dirName As String) As Long
Dim FileName As String
Dim FileSize As Currency
If Right$(dirName, 1) <> "/" Then
dirName = dirName & "/"
Endif
FileSize = 0
FileName = Dir$(dirName & "*.*")
Do While FileName <> ""
FileSize = FileSize + FileLen(dirName & FileName)
FileName = Dir$
Loop
DirUsedBytes = FileSize
end function
使用方法:
MsgBox DirUsedBytes("D:/musics")
新闻热点
疑难解答