When is a Storage Card an SD Card or a CF Card on Windows Mobile

A discussion I was party to alerted me to an interesting issue when writing file to a Storage Card on a Windows Mobile device. On most devices a storage card will appear as “Storage card” both in File Explorer and via code.  However, apparently this is not a rule that you can rely on and that on occasions the storage card might be called “SD Card”, “CF Card” or even “CF Card 2” (this is not an exhaustive list of all the options). 

So, you might ask – how do I locate the storage card?  Well you can do this my iterating through the folders at the root of your device.  For example (thanks to Ilya Tumanov from Microsoft for this code snippet):

For Each directory As String In Directory.GetDirectories(“”)
  If ((New DirectoryInfo(directory)).Attributes And FileAttributes.Temporary) <> 0 Then
     Console.WriteLine(“Found storage card: {0}”, directory)
  End If

Leave a comment