获取文件的图标或缩略图 [英] Get a file's icon or thumbnail

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

问题描述

在OSX SDK中,是否可以通过显示图标来在UI中表示文件? 换句话说,是否可以访问特定文件的图标,例如在NSImageView中显示它?

Is there a way, in OSX SDK, to represent a file in UI, by presenting its icon ? In other words, is it possible to access the icon for a specific file, to show it in a NSImageView for example ?

PS:我使用的是MonoMac,但是Objective-C代码当然也可以帮助我:)

PS: I'm using MonoMac, but Objective-C code will certainly help me too :)

预先感谢

推荐答案

您可以使用NSWorkspace的iconForFile:
例如:

You can use NSWorkspace's iconForFile:
e.g.:

[[NSWorkspace sharedWorkspace] iconForFile:@"/Applications/Launchpad.app"];

如果您需要某种文件类型的图标,则可以使用iconForFileType:

If you need icons for a certain file type, you can use iconForFileType:

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

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