Re: Move a file to the Trash
Re: Move a file to the Trash
- Subject: Re: Move a file to the Trash
- From: Nathan Day <email@hidden>
- Date: Wed, 6 Nov 2002 22:44:27 +1030
The simplest way to do this would be to just use NSAppleScript and
execute a script that tells finder to move the file to trash, this will
handle renaming the file if one of that name already exists with the
trash. You could just generate the string on the fly with the file path
contained with in it.
On Wednesday, November 6, 2002, at 08:38 PM, Lorenzo Puleo wrote:
Hi,
is someone that can suggest me how to move a file to the trash
properly?
Actually I use the APIs:
NSString *fileInTrash = [[NSHomeDirectory()
stringByAppendingPathComponent:@".Trash"]
stringByAppendingPathComponent:[myFile lastPathComponent]];
ok = [manager movePath:myFile toPath:fileInTrash handler:nil];
This guarantees that the file goes to the current user's trash. But
this
works properly only if the file is placed on the X boot disk.
Instead, when I tried to trash a file placed on a disk that is NOT my
boot
disk, that file has not been simply "moved" but "copied" to the trash
in the
boot disk then deleted from the original disk. This could require a
waste of
time.
Since my eternal disks have the invisible folder "Trash" placed in the
root,
I thought that I should move any external file to:
/Volumes/ExternalDisk/Trash/myFile
But I am not sure this is the solution.
How to do this properly? Carbon API "FindFolder"?
Thanks for any asnwer, sample code for Cocoa, links to PDF files,
tricks...
--
Lorenzo Puleo
mailto:email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
Nathan Day
http://homepage.mac.com/nathan_day/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.