0

I am working on a file explorer using Silverlight OOB. I need a way to get and display the icon associated with each file in my application. Note, I only need to show the icons, I don´t need to open the files.

Jeff Yates
  • 61,417
  • 20
  • 137
  • 189

1 Answers1

1

If I understood you right, you're building something like Windows Explorer and want to mimic its list view by showing the program icons right before their names.

I'm not sure whether OOB has access to the System.Drawing.Icon class, but if so, you can use the following code to get the icon for any given file:

Bitmap icon = System.Drawing.Icon.ExtractAssociatedIcon(filename).ToBitmap();

If not, the only way you can do it is by storing the icons for most common file formats in a dictionary and retrieving them from there based upon file extension.

Jeff Yates
  • 61,417
  • 20
  • 137
  • 189
Alexander Galkin
  • 12,086
  • 12
  • 63
  • 115