Getting Storage Information via Configuration Manager

I’m at a workshop that we’re running for ISVs and Enterprise Customers called the Mobile Line of Business Application Development workshop for the next 4 days. This workshop is a deepdive into content for architects and developers that cover all issues and tools that one would need to build LOB applications OR extend existing LOB applications to take advantage of the benefits of Mobility.

One question came up during the workshop about how one can retrieve storage information on the Windows Mobile device. Thanks to Jim Wilson, who in less time than it would take me to reboot my machine (really, I had to reboot my machine while I was talking to Jim), coded up a sample application that shows how you can do just that.

Basically all you need to do is to create an XML file that contains the following provisioning data:

    <characteristic type='DeviceInformation'>
        <parm-query name='AvailableStorage' /> 

and hand that off to the Configuration Manager. here’s the code snippet to do just that:

public static string GetAvailableStorage()
    Cursor.Current = Cursors.WaitCursor;

    const string inputXml = 
           <characteristic type='DeviceInformation'>
              <parm-query name='AvailableStorage' /> 
    const string availableStorageValueXPath = @"//parm[@name='AvailableStorage']/@value";

    XmlDocument inputDom = new XmlDocument();
    XmlDocument outputDom = ConfigurationManager.ProcessConfiguration(inputDom, false);

    XmlNode storageNode = outputDom.SelectSingleNode(availableStorageValueXPath);
    string availableStorage = (storageNode != null && storageNode.Value != null ? storageNode.Value : "<null>");

    Cursor.Current = Cursors.Default;

    return availableStorage;

very simple really. I’m sure most of you would already know this, but Configuration Manager can do a lot more than just return Storage Info. here’s a link to the reference if you wanted to know what else it can do.

Thanks again Jim! (btw, if you use this code, you’ll have to take it up with him to avoid paying royalties.. 🙂 )

Here’s Jim’s Adapt Your App page which contains more info:

Comments (3)

  1. Jim Wilson says:

    Depending on your monitor size, you may not be able to read all of the code in Loke’s post so I’ve put the sample project that goes w/ this post on my site.

    You can download the GetStrageInfo sample app from

    – Jim

  2. lokeuei says:

    ahh! thanks Jim!

  3. Henrik Bach says:

    So this apparently only works on SmartPhones? On Pocket PC WM5 emulator "<null>" is returned, but on SmartPhone WM5 emulator a "xx.xx MB" is returned.