如何获取任何文件/文件夹的系统图标 [英] How to get the system icon for any file/folder

查看:40
本文介绍了如何获取任何文件/文件夹的系统图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何检索与文件/文件夹关联的系统图标,以便我可以在文件/文件夹名称旁边的列表视图中显示它吗?

How can I retrieve the system icon associated with a file/folder so that I can show it in the list view adjacent to the file/folder name?

推荐答案

您需要使用 Icon.ExtractAssociatedIcon

 Icon icon = Icon.ExtractAssociatedIcon(filepath);

看看 Icon.ExtractAssociatedIcon 文档

注意:这仅适用于文件.对于文件夹,您需要P/Invoke

Note: this works only for files. For folders you need P/Invoke sample is here Page is now defunct, please refer to this copy on the Wayback Machine.

这篇关于如何获取任何文件/文件夹的系统图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆