简体   繁体   English

silverlight-文件扩展名

[英]silverlight - file extensions

I am working on a file explorer using Silverlight OOB. 我正在使用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. 如果我理解正确,那么您正在构建Windows Explorer之类的产品,并希望通过在程序图标名称之前显示程序图标来模仿其列表视图。

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: 我不确定OOB是否可以访问System.Drawing.Icon类,但是如果是这样,则可以使用以下代码获取任何给定文件的图标:

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. 如果没有,唯一的方法是将最常用文件格式的图标存储在字典中,然后根据文件扩展名从那里检索它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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