The right way to delete file to trash in Snow Leopard using Cocoa ?
- by Irwan
I mean the right way must able to "Put Back" in Finder and isn't playing sound
Here are the methods I tried so far:
NSString * name = @"test.zip";
NSArray * files = [NSArray arrayWithObject: name];
NSWorkspace * ws = [NSWorkspace sharedWorkspace];
[ws performFileOperation: NSWorkspaceRecycleOperation
source: @"/Users/"
destination: @""
files: files
tag: 0];
Downturn : can't "Put Back" in Finder
OSStatus status = FSPathMoveObjectToTrashSync(
"/Users/test.zip",
NULL,
kFSFileOperationDefaultOptions
);
Downturn : can't "Put Back" in Finder
tell application "Finder"
set deletedfile to alias "Snow Leopard:Users:test.zip"
delete deletedfile
end tell
Downturn : playing sound so it's annoying if I execute it repeatedly