Display pretty file icons in your ASP.NET applications with IconHandler

Do you like file icons? I do. They make it pretty easy to visually digest file lists in Windows, when you open a file system folder with explorer.

Displaying icons in your web application can also be pretty compelling (for example, to spruce up that boring directory listing page, or visually represent documents in your web app). Wouldn't it be cool if you can write an ASP.NET control or page that can embed these icons on your custom directory listing view?

Unfortinately, there is no easy way to get icons for files in the .NET framework, so you have to do a little interop with the Windows shell to get the icon for a file / file extension, and then figure out a way to serve it over the web as an image. So, I wrote an ASP.NET image handler that serves the icon for an aritrary file or extension, that you can simply drop into your application to get these pretty icons for whatever purposes you need.

Read more on http://mvolo.com/blogs/serverside/archive/2007/01/11/Display-pretty-file-icons-in-your-ASP.NET-applications-with-IconHandler.aspx.

No Comments