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…