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/microsoft.public.dotnet.framework.compactframework/browse_thread/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.

Re: I have a problem with the GetDiskFreeSpaceEx by ctacke/>

ctacke/>
Wed Sep 19 15:06:57 PDT 2007

I answered this elsewhere (probably in the thread you're giving us a link
to) - don't start a new thread.

The return for GetDiskFreeSpaceEx is a native BOOL, which is #defined to a
32-bit int. That translates to a VB Integer or Int32, not a Long as you
have it defined.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com




<amiga500@gmail.com> wrote in message
news:1190225149.284477.49800@50g2000hsm.googlegroups.com...
> 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/microsoft.public.dotnet.framework.compactframework/browse_thread/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.
>



Re: I have a problem with the GetDiskFreeSpaceEx by amiga500

amiga500
Thu Sep 20 06:10:50 PDT 2007

On Sep 19, 6:06 pm, "<ctacke/>" <ctacke[at]opennetcf[dot]com> wrote:
> I answered this elsewhere (probably in the thread you're giving us a link
> to) - don't start a new thread.
>
> The return for GetDiskFreeSpaceEx is a native BOOL, which is #defined to a
> 32-bit int. That translates to a VB Integer or Int32, not a Long as you
> have it defined.
>
> --
>
> Chris Tacke, Embedded MVP
> OpenNETCF Consulting
> Managed Code in an Embedded Worldwww.OpenNETCF.com
>
> <amiga...@gmail.com> wrote in message
>
> news:1190225149.284477.49800@50g2000hsm.googlegroups.com...
>
> > 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/microsoft.public.dotnet.framework.comp...
>
> > 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
>
You keep saying it the variable type but to my demsie when I followed
your advice it failed there too. Why do you think I keep requesting
help in this regard?

> > '' 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.



Re: I have a problem with the GetDiskFreeSpaceEx by amiga500

amiga500
Thu Sep 20 06:21:52 PDT 2007

I am sorry. You are right as usual and I am wrong as usual. I fixed it
and it worked. You are one hundred percent I am one hundred percent
wrong, forgive me. No more posting in this regard anymore.