Thursday, January 18, 2007

add Windows icons to your web app

Whenever you build a file explorer interface for a web application (such as telerik's File Explorer demo), you almost always face the tedious task of finding or creating all of the "icon files" you need for the file types you expect your explorer to handle. You try to use Snag-it and Photoshop to create image files of the icons you see in your Windows file explorer, hoping that you catch most of the obvious file types and leaving the rest to display your fancy "generic" file icon. Why can't we just use existing Windows icon files in our web applications?

Now you can. Mike Volodarsky, Microsoft Program Manager for the IIS7 web server engine, has created a demo project that uses a custom HttpHandler to serve up PNG versions or any icon on your Windows machine. You simply supply the handler with a file type (such as ".ppt") or a filename and the handler returns the PNG version of the icon associated with that file type.
While the project makes it much easier to get icons for all file types into your web file explorer, you must remember that it can only load icons that exist on your web server (which very often does not have productivity software like Office installed). In those cases, you'll still have to use the old fashion static image files to get the job done.