C# 中的简单文件和文件夹视图
我最近看到一个应用程序有两个简单的控件(一个树视图和一个详细的列表视图),用于列出目录和文件。我知道如何做到这一点,但除了列出文件之外,它还有另一个不错的功能:它从系统 shell 加载信息,例如文件夹图标、文件规范(主要是文件类型,从系统继承,所以如果我有一个应用程序什么将 SVG 文件类型修改为“未知矢量图形内容”,然后它显示所有 SVG 文件的类型为之前的该字符串)。
我想请问您,如何在不使用任何第三方库的情况下轻松实现这些功能?
I have seen an application recently what had two simple controls (a treeView and a detailed ListView) what were used for listing directories and files. I know how to do this, but it had another nice feature other than listing files: it loaded info from the system shell, like icons of folders, file specifications (file types mostly, inherited from the system, so if I had an application what modified the SVG file type to "Unknown vectorgraphic stuff" then it showed all SVG file's type as this string before).
I would like to ask You, that how could I make these features easily without using any third party library?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您还可以考虑使用现成的控件,例如 Shell MegaPack,它显示这样的文件/文件夹相同的图标、细节、菜单等
You can also consider using ready-made controls like Shell MegaPack which show files/folders like this with same icons, details, menus, etc
您可以通过 System.Drawing.Icon.ExtractAssociatedIcon() 获取文件的图标...
you can get icon for a file by System.Drawing.Icon.ExtractAssociatedIcon()...