简体   繁体   中英

silverlight - file extensions

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM