Results 1 to 3 of 3

Thread: Problem with FileSystemObject

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Posts
    15
    I was using the filesystemobject to get the size of the fixed drives on my machine. However, the totalsize property returns a 20 GB drive and I only have an 8 GB drive. Is there any way to get the correct size, or do I need to do it a different way?
    That's not a BUG, It's a feature!



    VB6 Professional Service Pack 3
    Windows CE Embedded Visual Tools 3

  2. #2
    Guest
    You can use GetFreeDiskSpaceEx.
    Code:
    Private Declare Function GetDiskFreeSpaceEx Lib "kernel32.dll" Alias "GetDiskFreeSpaceExA" (ByVal lpDirectoryName As String, lpFreeBytesAvailableToCaller As ULARGE_INTEGER, lpTotalNumberOfBytes As ULARGE_INTEGER, lpTotalNumberOfFreeBytes As ULARGE_INTEGER) As Long
    Private Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
    
    Private Type ULARGE_INTEGER
      LowPart As Long
      HighPart As Long
    End Type
    
    Dim FreeUser As ULARGE_INTEGER
    Dim Total As ULARGE_INTEGER
    Dim FreeSys As ULARGE_INTEGER
    Dim Temp As Currency
    Dim fTemp As Currency
    
    Private Sub Command1_Click()
        GetDiskFreeSpaceEx "C:\", FreeUser, Total, FreeSys
        CopyMemory Temp, Total, 8
        CopyMemory fTemp, FreeUser, 8
        Print "Total Space: " & (CCur(Temp) * 10000) / 1000000000 & " GB"
        Print "Free Space: " & (CCur(fTemp) * 10000) / 1000000000 & " GB"
    End Sub

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Posts
    15
    Thanks Megatron
    That's not a BUG, It's a feature!



    VB6 Professional Service Pack 3
    Windows CE Embedded Visual Tools 3

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width