Checking Available Disk Space.

Checking Available Disk Space.

am 27.01.2008 08:18:53 von elias.farah

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.availablespace but again, was
unable to get it working.

Any suggestions would be appreciated. Thank you very much!

-- Code below --




Declare Function GetDiskFreeSpaceEx Lib "kernel32" _
Alias "GetDiskFreeSpaceExA" _
(ByVal lpcurRootPathName As String, _
lpFreeBytesAvailableToCaller As Currency, _
lpTotalNumberOfBytes As Currency, _
lpTotalNumberOfFreeBytes As Currency) As Long

Sub FreeBytes(NetworkShare As String)

Dim curBytesFreeToCaller As Currency
Dim curTotalBytes As Currency
Dim curTotalFreeBytes As Currency

Call GetDiskFreeSpaceEx(NetworkShare, _
curBytesFreeToCaller, _
curTotalBytes, _
curTotalFreeBytes)

'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$(curTotalBytes * 10000, "###,###,###,##0") & " bytes"

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

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

Debug.Print " Total Space Used :", Format$((curTotalBytes -
curTotalFreeBytes) * 10000, "###,###,###,##0") & " bytes"

End Sub

Re: Checking Available Disk Space.

am 27.01.2008 18:05:30 von kobd

Hi,

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

i'd try to run the SysInfo sample from Attac Group in Vista

http://www.groupacg.com/files/sysinfo9.zip

If it runs then look for the code, if not ...


--
mit freundlichen Grüßen aus Nürnberg

Klaus Oberdalhoff KObd@gmx.de
Ich unterstütze PASS Deutschland e.V. (http://www.sqlpass.de)
Nächstes Treffen in Nürnberg am 12.02.2008