Ok ... i did a little bit more of research ....
There IS a way to check the REAL free space ...
I get some Clues for the right way from here http://msdn.microsoft.com/en-us/library/aa363940(VS.85).aspx
So if you want take a look ...
Here are some Code samples VB.NET, and VBA seperatly tested ....
First we need To check if Path is a Mountpoint ....
There is a Managed NET way - there is an file attribute which named somthing like SPARSE PONT or so ... but i diddent followed that way
There is a Kernl32 Function named "GetVolumeNameForVolumeMountPoint" which returns the Name of the volumemountpoint which looks like:
\\?\Volume{127a8f79-9a12-11dd-bab2-001e4f94e955}\
All Drives / Partitions / Volumes not only the mounted Folders have a name like this (Try at commandline: mountvol)
A Driveletter is also a Mountpoint, but at Root Level (C:\ or D:\ ...)
then we take the Parity Path and Test it with the "GetVolumeNameForVolumeMountPoint" Function,
if we get an empty string back then we strip the last folder from the Path and try it again.
Until we reach the Root -> then we have a Volume mounted by Driveletter and you use your old way to check Free space.
If we get something like \\?\Volume... back then we have fonde a mounted Folder and know the MountVolumeGUIDPath.
At next we have to check the Free Space on the drive but how without Diveletter !?
GetDiskFreeSpaceEx from also kernl32 do the Job.
Important is to double the last Backslash at end as example if "GetVolumeNameForVolumeMountPoint" returns
\\?\Volume{127a8f79-9a12-11dd-bab2-001e4f94e955}\
then you have to extend it with a \ at the end so you get
\\?\Volume{127a8f79-9a12-11dd-bab2-001e4f94e955}\\
This path also works at commandline as example: dir \\?\Volume{127a8f79-9a12-11dd-bab2-001e4f94e955}\\
by using GetDiskFreeSpaceEx(Drive, lFreeBytesAvailable, lBytesTotal, lFreeBytes)
where Drive is the "\\?\Volume{GUID}\\" string we get the Free Bytes ... i didnt researchd whats the difference between FreeBytesAvailable and FreeBytes
So the a little bit of Code To Get the VolumeGUIDPath form Path:
Private Declare Function GetVolumeNameForVolumeMountPoint Lib "kernel32" Alias "GetVolumeNameForVolumeMountPointA" (ByVal lpszVolumeMountPoint As String, ByVal lpszVolumeName As String, ByVal cchBufferLength As Long) As Long
Function GetVolumeFromDrive(sVolumeMountPoint As String) As String
Dim buff As String
Dim cbbuff As Long
buff = Space$(1024)
cbbuff = Len(buff)
If GetVolumeNameForVolumeMountPoint(sVolumeMountPoint, buff, cbbuff) <> 0 Then
GetVolumeFromDrive = TrimNull(buff)
End If
End Function
And for the Free Space :
Declare Auto Function GetDiskFreeSpaceEx Lib "kernel32" (ByVal lpDirectoryName As String, ByRef lpFreeBytesAvailableToCaller As Long, ByRef lpTotalNumberOfBytes As Long, ByRef lpTotalNumberOfFreeBytes As Long) As Long
Public Function GetFreeSpace(ByVal Drive As String) As Long
Dim lBytesTotal, lFreeBytes, lFreeBytesAvailable As Long
Dim iAns As Long
iAns = GetDiskFreeSpaceEx(Drive, lFreeBytesAvailable, lBytesTotal, lFreeBytes)
return lFreeBytesAvailable
End Function
I diddnt tried both togeter , one i tested in VBA the other is VB.NET code, but i think ist easy to figur out how it works ...
Another Possiblity to make it more simple is to extend the config file by something like:
We keep the normal Parity= setting .... you need it to access the Files .... and extend by :
ParityVolume=\\?\Volume{127a8f79-9a12-11dd-bab2-001e4f94e955}\
If this Option exist you only have to use the last Funtion to get the free space ...
If not you use your old way ....
This Method is a little bit faster and every user can get the VolumeGUID simple by entering mountvol in commandline and copy the string ...
And ... dont feel forecd by me to implemet this ... its only a suggestion ....