Verzeichnisgrösse berechnen

FindClose, FindFirstFile, FindNextFile
Private Type FILETIME
  dwLowDateTime As Long
  dwHighDateTime As Long
End Type
Private Const MAX_PATH = 260
Private Const FILE_ATTRIBUTE_DIRECTORY = &H10
Private Type WIN32_FIND_DATA
  dwFileAttributes As Long
  ftCreationTime As FILETIME
  ftLastAccessTime As FILETIME
  ftLastWriteTime As FILETIME
  nFileSizeHigh As Long
  nFileSizeLow As Long
  dwReserved0 As Long
  dwReserved1 As Long
  cFileName As String * MAX_PATH
  cAlternate As String * 14
End Type
Private Declare Function FindClose Lib "kernel32" (ByVal hFindFile As Long) As Long
Private Declare Function FindFirstFile Lib "kernel32" Alias "FindFirstFileA" _
 (ByVal lpFileName As String, lpFindFileData As WIN32_FIND_DATA) As Long
Private Declare Function FindNextFile Lib "kernel32" Alias "FindNextFileA" _
 (ByVal hFindFile As Long, lpFindFileData As WIN32_FIND_DATA) As Long
Function GetDirectorySize(ByVal Root$) As Double Function to calculate bytes used in Root$ and all
Dim FData As WIN32_FIND_DATA subdirectories of Root$
Dim fHand& Root$ should be entered in the form c:\Dir
Dim sPath$
Dim StillOK&
Dim ByteTotal&
Dim nPos%
Dim DirName$
sPath$ = Root$ + "\*.*"
fHand& = FindFirstFile(sPath$, FData)
If fHand& <= 0 Then
GetDirectorySize = 0
Exit Function
End If
ByteTotal& = 0
Do
If (FData.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY) = FILE_ATTRIBUTE_DIRECTORY Then
  nPos% = InStr(FData.cFileName, Chr$(0))
  DirName$ = Left$(FData.cFileName, nPos% - 1)
    If DirName$ <> "." And DirName$ <> ".." Then
      ByteTotal& = ByteTotal& + GetDirectorySize(Root$ + "\" + DirName$)
    End If
Else
  ByteTotal& = ByteTotal& + FData.nFileSizeLow
End If
StillOK& = FindNextFile(fHand&, FData)
Loop Until StillOK = 0
fHand& = FindClose(fHand&)
GetDirectorySize = ByteTotal&
End Function



 Ranking-Hits zurück Sitemap
Designed by www.wbrnet.info