Getting an SD Card Serial Number in the Compact Framework

Another nice addition to the latest drop of the SDF is the ability to get the serial number and manufacturer ID of storage volumes that support it (like SD cards). We did this by simply extending the existing OpenNETCF.IO.DriveInfo class to add a couple new properties.  Here’s a quick example of how it works:


foreach(var info in DriveInfo.GetDrives())
{
  Debug.WriteLine(“Info for “ + info.RootDirectory);
  Debug.WriteLine(“tSize: “ + info.TotalSize.ToString());
  Debug.WriteLine(“tFree: “ + info.AvailableFreeSpace.ToString());
  Debug.WriteLine(“tManufacturer: “ + info.ManufacturerID ?? “[Not available]”);
  Debug.WriteLine(“tSerial #: “ + info.SerialNumber ?? “[Not available]”);
  Debug.WriteLine(string.Empty);
}

4 thoughts on “Getting an SD Card Serial Number in the Compact Framework”

  1. Does this return the serial sumber of the SD Card itself, or the volume on the SD Card? If it’s actually getting the serial number of the SD Card, that value will not change if the card is reformatted.

    Like

  2. I have been scouring around the net trying to find some code that will run under Windows Mobile that can read the volume serial number(the number that changes with each format) I can find nothing. I have seen posts going back as far as 2003, I find it hard to believe nobody has found a straight forward wy to get this info as of yet. I have been able with pInvoke to get the device serial but don’t want that.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s