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:

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

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 = 
        @"<wap-provisioningdoc>
           <characteristic type='DeviceInformation'>
              <parm-query name='AvailableStorage' /> 
           </characteristic>
        </wap-provisioningdoc>";
    const string availableStorageValueXPath = @"//parm[@name='AvailableStorage']/@value";

    XmlDocument inputDom = new XmlDocument();
    inputDom.LoadXml(inputXml);
    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: http://pluralsight.com/blogs/jimw/archive/2006/07/31/32713.aspx