anyone know?
Printable View
anyone know?
*bump*
Hi,
I think u can use the API "GetFileSize"
Anita
Something similar to:
VB Code:
Dim FSO, FSOf Set FSO = CreateObject("Scripting.FileSystemObject") Set FSOf = FSO.GetFolder(thisFolder) lblDateCreated = DisplayDate(FSOf.DateCreated) lblDateModified = DisplayDate(FSOf.DateLastModified) lblSize = FormatNumber(Round(FSOf.Size / 1024, 1), 0) & " KBytes"
If you would prefer not to use the FSOVB Code:
Private Const MAX_PATH = 260 Private Type FILETIME dwLowDateTime As Long dwHighDateTime As Long End Type 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 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 Private Declare Function FindClose Lib "kernel32" (ByVal hFindFile As Long) As Long Private Function EndSlash(ByVal PathIn As String) As String If Right$(PathIn, 1) = "\" Then EndSlash = PathIn Else EndSlash = PathIn & "\" End If End Function Private Function SizeOf(ByVal DirPath As String) As Double Dim hFind As Long Dim fdata As WIN32_FIND_DATA Dim dblSize As Double Dim sName As String Dim x As Long On Error Resume Next x = GetAttr(DirPath) If Err Then SizeOf = 0: Exit Function If (x And vbDirectory) = vbDirectory Then dblSize = 0 Err.Clear sName = Dir$(EndSlash(DirPath) & "*.*", vbSystem Or vbHidden Or vbDirectory) If Err.Number = 0 Then hFind = FindFirstFile(EndSlash(DirPath) & "*.*", fdata) If hFind = 0 Then Exit Function Do If (fdata.dwFileAttributes And vbDirectory) = vbDirectory Then sName = Left$(fdata.cFileName, InStr(fdata.cFileName, vbNullChar) - 1) If sName <> "." And sName <> ".." Then dblSize = dblSize + SizeOf(EndSlash(DirPath) & sName) End If Else dblSize = dblSize + fdata.nFileSizeHigh * 65536 + fdata.nFileSizeLow End If DoEvents Loop While FindNextFile(hFind, fdata) <> 0 hFind = FindClose(hFind) End If Else On Error Resume Next dblSize = FileLen(DirPath) End If SizeOf = dblSize End Function Private Sub Command1_Click() 'Replace 'c:\windows' with the directory name that you want to get its size. Screen.MousePointer = vbHourglass MsgBox SizeOf("c:\windows") Screen.MousePointer = vbDefault End Sub