Critical Development

Language design, framework development, UI design, robotics and more.

Listing Storage Card Paths in Compact Framework

Posted by Dan Vanderboom on March 10, 2008

Getting a list of storage card paths on a Windows CE or Windows Mobile device from Compact Framework is a lot more complicated than it should be.  After finding references to FindFirstFlashCard and FindNextFlashCard, which require interop calls, I found this helpful MSDN article which talks about a way of obtaining storage card folder names without using interop. 

However, there are a few problems with it.  First, attrStorageCard is not defined.  If you’re interested in that technique, use this:

FileAttributes attrStorageCard = FileAttributes.Directory | FileAttributes.Temporary;

Second, with the device that I’m working on (made by DAP), that method returned not only the storage card, but also a DiskOnChip folder (fair enough), and a folder called Network, which I can only guess is some kind network-mapped directory.  I didn’t want to include this Network folder and then have to create some kind of exclusion rule for it, so I decided to take the interop route and try FindFirstFlashCard using code from this website.

I didn’t have any luck there either, unfortunately, because the DAP device I’m working with doesn’t have the required note_prj.dll file.  Foo.

Eventually I stumbled across a registry setting at HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\MMC\Folder, which is set to “Storage Card” for my device.  I really dislike using the registry for this, and I’m hoping it will work for other manufacturer’s devices.  Because it’s a Microsoft area of the registry, I’m fairly confident this will be the case.  I was informed that the DAP device I’m developing for likes to randomly change its storage card path to “Storage Card2”, so I’ll have to check that this registry setting is updated when that happens.

I’m going to say a little prayer to the Compact Framework dieties to add some better managed support for accessing common device functionality like storage cards.  CF really is a great platform, but the learning curve is still pretty painful after all this time.

I wonder how Google’s Android API exposes things like this…

Advertisements

3 Responses to “Listing Storage Card Paths in Compact Framework”

  1. Angy said

    can you explain me more how you do with system of registrykey. I have the same problem with a DAP device.

  2. Dan Vanderboom said

    It won’t work on a DAP device. In fact, sometimes a DAP device will spontaneously rename the storage card to “storage card2” for no clear reason. We’re moving away from DAP because of stability problems.

  3. Jason Garrett said

    The best fix for this I’ve found is to change the timers relating to the SD Card Power Management, and the time it takes to start back up after a suspend.

    http://www.mydigitallife.info/2008/06/25/fix-sd-memory-card-disappearing-missing-folder-or-corrupt-in-windows-mobile-device/

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

 
%d bloggers like this: