Checking Available Disk Space.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • elias.farah@scw.com.au

    #1

    Checking Available Disk Space.

    Hello Everyone,

    I've been searching for a few hours on how to check the available disk
    space (on a Flash disk actually) from within MS-Access.

    Basically, I want to ensure there is adequate room on the Flash drive
    before a Backup is attempted.

    I've been trying to get Doug's code working within Access 2007 (and
    Vista x64), but it doesn't seem to work for me. I pasted this into a
    Module by itself, but calling it just gives Nothing. No error, no
    return values.

    I saw a value post about using fs.availablespa ce but again, was
    unable to get it working.

    Any suggestions would be appreciated. Thank you very much!

    -- Code below --




    Declare Function GetDiskFreeSpac eEx Lib "kernel32" _
    Alias "GetDiskFreeSpa ceExA" _
    (ByVal lpcurRootPathNa me As String, _
    lpFreeBytesAvai lableToCaller As Currency, _
    lpTotalNumberOf Bytes As Currency, _
    lpTotalNumberOf FreeBytes As Currency) As Long

    Sub FreeBytes(Netwo rkShare As String)

    Dim curBytesFreeToC aller As Currency
    Dim curTotalBytes As Currency
    Dim curTotalFreeByt es As Currency

    Call GetDiskFreeSpac eEx(NetworkShar e, _
    curBytesFreeToC aller, _
    curTotalBytes, _
    curTotalFreeByt es)

    'show the results, multiplying the returned
    'value by 10000 to adjust for the 4 decimal
    'places that the currency data type returns.
    Debug.Print " Total Number Of Bytes:", _
    Format$(curTota lBytes * 10000, "###,###,###,## 0") & " bytes"

    Debug.Print " Total Free Bytes:", _
    Format$(curTota lFreeBytes * 10000, "###,###,###,## 0") & "
    bytes"

    Debug.Print " Free Bytes Available:", _
    Format$(curByte sFreeToCaller * 10000, "###,###,###,## 0") & "
    bytes"

    Debug.Print " Total Space Used :", Format$((curTot alBytes -
    curTotalFreeByt es) * 10000, "###,###,###,## 0") & " bytes"

    End Sub


Working...