试试:SHGetFileInfo Function
Declare Function SHGetFileInfo Lib "shell32.dll" Alias "SHGetFileInfoA" (ByVal pszPath As Any, ByVal dwFileAttributes As Long, psfi As SHFILEINFO, ByVal cbFileInfo As Long, ByVal uFlags As Long) As LongParameterspszPath
The name of the file, directory, or drive to retrieve information about.

解决方案 »

  1.   

    为什么 不用 这个(非API):
    Sub ShowFolderSize(filespec)
        Dim fs, f, s
        Set fs = CreateObject("Scripting.FileSystemObject")
        Set f = fs.GetFolder(filespec)
        s = UCase(f.Name) & " uses " & f.size & " bytes."
        MsgBox s, 0, "Folder Size Info"
    End Sub
      

  2.   


    需要遍历。
    需要两个控件。 FileList 命名为fileSearchFiles(其中属性如时候显示隐藏文件也影响搜索结果,自己设置),DirList命名为dirSearchFiles
    Private Sub SearchFiles(ByVal szStartDir As String)
    Dim i As Long, t As Stringt = dirSearchFiles.PathdirSearchFiles.Path = szStartDir
    fileSearchFiles.Path = szStartDirFor i = 0 To fileSearchFiles.ListCount - 1
      DoWithFile GetFileFullName(szStartDir, fileSearchFiles.List(i))
      找到了文件!处理大小,用 FileLen累计就可以了。
      DoEvents
    Next
    For i = 0 To dirSearchFiles.ListCount - 1
      SearchFiles dirSearchFiles.List(i)
      DoEvents
    NextdirSearchFiles.Path = t
    End SubPublic Function GetFileFullName(ByVal p As String, ByVal fn As String) As String
    If Right(p, 1) = "\" Then
      GetFileFullName = p + fn
    Else
      GetFileFullName = p + "\" + fn
    End If
    End Function