开发者

Using NSWorkspace selectFile:inFileViewerRootedAtPath: with files on the desktop

开发者 https://www.devze.com 2023-03-12 06:44 出处:网络
You can do something like this to have the finder open a window and select a file: [[NSWorkspace sharedWorkspace] selectFile:file inFileViewerRootedAtPath:root]

You can do something like this to have the finder open a window and select a file:

[[NSWorkspace sharedWorkspace] selectFile:file inFileViewerRootedAtPath:root]

This is fine for most files, but as far as I can work out, if the file is on the desktop, the Finder will still open a viewer window for it, even if you pass the path to the desktop as the root.

Has anyone worked out a way to get the Finder to simply select the file on the desktop?

Is there something sneaky that one can pass as root to convince the Finder to do 开发者_JS百科the sensible thing?

I imagine that I could write an applescript to do what I want, but I can't help feeling that there ought to be an easier way...

0

精彩评论

暂无评论...
验证码 换一张
取 消