Check SD card Memory and

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

Guest

Hi Guys,

I want to check the SD card rest memory.and also want to check if there
is a SD card or not on DOT NET ?

Is there any api there?

and how to implement it?

My enviroment is: CF2.0
VS2005

Thanks
 
I don't know of any APIs that would cater to your needs. However, you
can find out whether or not you have an SD card by doing

if(Directory.Exists(@"/Storage Card"))

You might as well check out DirectoryInfo class to see if it has any
memory related properties.

Krupa
 
Hi Jeff,
PInvoke GetDiskFreeSpaceEx to get the storage card free space, follow
Krupa's thread for checking the directory exist.

Code snippet:

[DllImport("coredll.dll")]
private static extern bool GetDiskFreeSpaceEx(string
lpDirectoryName,out ulong lpFreeBytesAvailableToCaller,
out ulong lpTotalNumberOfBytes,out ulong
lpTotalNumberOfFreeBytes);

Usage:
ulong freeBytesAvailable, totalBytesAvailable, freeBytesTotal;
if (GetDiskFreeSpaceEx(storagePath, out
freeBytesAvailable, out totalBytesAvailable, out freeBytesTotal) ==
true)
{
totalBytes = Convert.ToInt32(totalBytesAvailable);
availBytes = (int)freeBytesAvailable;
}

Hope this helps,
Cheers,
Arun
www.innasite.com
 
Back
Top