A
amiga500
Hello
I have discovered that someone else have the same problem as me when
it comes to GetDiskFreeSpaceEx, the only problem is I am unable to
resolve it while he have.
http://groups.google.com/group/micr...read/thread/aa8c310704610a9b/e5d1314010a16ae8
Above is the link for the discussion for that problem I have. Can
someone help me? Please click the link above as I have posted my
problem there but discovered it did not bump the topic to the top
list. Thanks in advance.
------------------ For the lazy people I have posted the problem below
in fear people will not click the link ----------
Hello,
I have same problem but I am unable to solve it. Here is my code:
--- Declaration
Private Declare Function GetDiskFreeSpaceEx Lib "coredll.dll" Alias
"GetDiskFreeSpaceEx" (ByVal lpDirectoryName As String, ByRef
lpFreeBytesAvailableToCaller As Long, ByRef lpTotalNumberOfBytes As
Long, ByRef lpTotalNumberOfFreeBytes As Long) As Long
--- Function
Public Function GetFreeSpace(ByVal Drive As String) As Long
'returns free space in MB, formatted to two decimal places
'e.g., msgbox("Free Space on C: "& GetFreeSpace("C:\") & "MB")
Dim lBytesTotal, lFreeBytes, lFreeBytesAvailable As Long
Dim iAns As Integer
iAns = GetDiskFreeSpaceEx(Drive, lFreeBytesAvailable, _
lBytesTotal, lFreeBytes)
If iAns > 0 Then
Return BytesToMegabytes(lFreeBytes)
Else
Throw New Exception("Invalid or unreadable drive")
End If
End Function
Public Function GetTotalSpace(ByVal Drive As String) As String
'returns total space in MB, formatted to two decimal places
'e.g., msgbox("Free Space on C: "& GetTotalSpace("C:\") &
"MB")
Dim lBytesTotal, lFreeBytes, lFreeBytesAvailable As Long
Dim iAns As Integer
iAns = GetDiskFreeSpaceEx(Drive, lFreeBytesAvailable, _
lBytesTotal, lFreeBytes)
If iAns > 0 Then
Return BytesToMegabytes(lBytesTotal)
Else
Throw New Exception("Invalid or unreadable drive")
End If
End Function
Private Function BytesToMegabytes(ByVal Bytes As Long) _
As Long
Dim dblAns As Double
dblAns = (Bytes / 1024) / 1024
BytesToMegabytes = Format(dblAns, "###,###,##0.00")
End Function
--- Use
'' SqlMobile.sdf located in Program Files\daedalusmobile
If GetFreeSpace("\Program Files\daedalusmobile\") <= 1 Then
If MessageBox.Show("You are low or out of space. Please
dock your equipment, complete some tasks, and then synchronize.",
MessageBoxButtons.OK) = DialogResult.OK Then
MyApp.fs.Stop()
End If
End If
When I run the program I get this error message:
NotSupportedException
Can someone please help me? Thanks in advance.
I have discovered that someone else have the same problem as me when
it comes to GetDiskFreeSpaceEx, the only problem is I am unable to
resolve it while he have.
http://groups.google.com/group/micr...read/thread/aa8c310704610a9b/e5d1314010a16ae8
Above is the link for the discussion for that problem I have. Can
someone help me? Please click the link above as I have posted my
problem there but discovered it did not bump the topic to the top
list. Thanks in advance.
------------------ For the lazy people I have posted the problem below
in fear people will not click the link ----------
Hello,
I have same problem but I am unable to solve it. Here is my code:
--- Declaration
Private Declare Function GetDiskFreeSpaceEx Lib "coredll.dll" Alias
"GetDiskFreeSpaceEx" (ByVal lpDirectoryName As String, ByRef
lpFreeBytesAvailableToCaller As Long, ByRef lpTotalNumberOfBytes As
Long, ByRef lpTotalNumberOfFreeBytes As Long) As Long
--- Function
Public Function GetFreeSpace(ByVal Drive As String) As Long
'returns free space in MB, formatted to two decimal places
'e.g., msgbox("Free Space on C: "& GetFreeSpace("C:\") & "MB")
Dim lBytesTotal, lFreeBytes, lFreeBytesAvailable As Long
Dim iAns As Integer
iAns = GetDiskFreeSpaceEx(Drive, lFreeBytesAvailable, _
lBytesTotal, lFreeBytes)
If iAns > 0 Then
Return BytesToMegabytes(lFreeBytes)
Else
Throw New Exception("Invalid or unreadable drive")
End If
End Function
Public Function GetTotalSpace(ByVal Drive As String) As String
'returns total space in MB, formatted to two decimal places
'e.g., msgbox("Free Space on C: "& GetTotalSpace("C:\") &
"MB")
Dim lBytesTotal, lFreeBytes, lFreeBytesAvailable As Long
Dim iAns As Integer
iAns = GetDiskFreeSpaceEx(Drive, lFreeBytesAvailable, _
lBytesTotal, lFreeBytes)
If iAns > 0 Then
Return BytesToMegabytes(lBytesTotal)
Else
Throw New Exception("Invalid or unreadable drive")
End If
End Function
Private Function BytesToMegabytes(ByVal Bytes As Long) _
As Long
Dim dblAns As Double
dblAns = (Bytes / 1024) / 1024
BytesToMegabytes = Format(dblAns, "###,###,##0.00")
End Function
--- Use
'' SqlMobile.sdf located in Program Files\daedalusmobile
If GetFreeSpace("\Program Files\daedalusmobile\") <= 1 Then
If MessageBox.Show("You are low or out of space. Please
dock your equipment, complete some tasks, and then synchronize.",
MessageBoxButtons.OK) = DialogResult.OK Then
MyApp.fs.Stop()
End If
End If
When I run the program I get this error message:
NotSupportedException
Can someone please help me? Thanks in advance.