Application and File Icons with Mobile In The Hand 4.0

There are a number of scenarios in which you want to retrieve the icon associated with a particular executable or other file type. One example is when building a file browser, you might also want to extract the icon associated with your application or another. The full .NET framework contains Icon.ExtractAssociatedIcon() for this very purpose. Mobile In The Hand includes a helper function to achieve the same result from the Compact Framework. Simply use the following code:-

  1. Icon i = IconHelper.ExtractAssociatedIcon(filePath);

filePath is the full path to any file. The icon will either be the icon associated with a particular file type or in the case of executables will be the embedded application icon (or a generic application icon if not present). The result is a regular System.Drawing.Icon type which you can draw using the Graphics class normally.

The documentation for the IconHelper class is available in the online library. For more information about Mobile In The Hand see the product page.