Network Drive Free Space

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How can I find out how much free space is available on a network drive
referenced using the "\\xxx..." terminology?

It appears that fs.AvailableSpace and fs.FreeSpace only work with "lettered"
drive designators.

Thanks,
Bruce
 
I don't know if there's a simpler way, but you could use the
SHGetDiskFreeSpace() Windows API function.
 
John,
Do you have example code, or know where I can find?
Thanks,
Bruce
 
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
 
Thanks, Doug!

Douglas J Steele said:
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
 
Use 'Tools' - 'Map Network Drive' then Rt.-Click the mapped drive to show
free space.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top