How to programmatically detect Storage Card capacity and free space?

Hi all,

how can I programmatically obtain how much space left on given SD Card? I can easily enumerate then on Windows Mobile, but a bit lost on their info retrieval. I can get the info about Program/Storage memory without any problems.

It seems that I miss some easy bit for SD cards :)

LVL 24
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Public Function GetSize(ByRef directoryName As String) As DiskFreeSpace

Dim result As New DiskFreeSpace

If GetDiskFreeSpaceEx(directoryName, result.FreeBytesAvailable,
result.TotalBytes, result.TotalFreeBytes) = False Then

Throw New
System.ComponentModel.Win32Exception(Marshal.GetLastWin32Error(), "Error
retrieving free disk space")

End If

Return result

End Function

Public Structure DiskFreeSpace

Public FreeBytesAvailable As Long

Public TotalBytes As Long

Public TotalFreeBytes As Long

End Structure

Private Declare Function GetDiskFreeSpaceEx Lib "coredll.dll" (ByVal
directoryName As String, ByRef freeBytesAvailable As Int32, ByRef totalBytes
As Int32, ByRef totalFreeBytes As Int32)

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim Freespace As New DiskFreeSpace
Freespace = GetSize("\")
End Sub

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
alexey_gusevAuthor Commented:
Thanks, Mikal!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Smartphone Programming

From novice to tech pro — start learning today.