我的意思是正确的方法必须能够“放回”Finder而不是播放声音
以下是我到目前为止尝试的方法:
NSString * name = @"test.zip";
NSArray * files = [NSArray arrayWithObject: name];
NSWorkspace * ws = [NSWorkspace sharedWorkspace];
[ws performFileOperation: NSWorkspaceRecycleOperation
source: @"/Users/"
destination: @""
files: files
tag: 0];
低迷:无法在Finder中“放回”
OSStatus status = FSPathMoveObjectToTrashSync(
"/Users/test.zip",
NULL,
kFSFileOperationDefaultOptions
);
低迷:无法在Finder中“放回”
tell application "Finder"
set deletedfile to alias "Snow Leopard:Users:test.zip"
delete deletedfile
end tell
低迷:播放声音,如果我反复执行它会很烦人
答案 0 :(得分:1)
我想如果你想“退回”那么AppleScript就是你要走的路。通过静音音量,移动文件,然后取消音量静音,我能够在没有任何声音的情况下完成此操作。注意我需要延迟才能使它工作。
set f to (path to desktop folder as text) & "myFile.txt"
set volume with output muted
tell application "Finder" to move file f to trash
delay 1
set volume without output muted