Search code examples
objective-ccocoarecycle-bin

how to list the content of the trash using objective-c (in a mac)


I am tying to get the content of the trash in a Cocoa application and I was wondering if this is a special path or if I have to use dedicated functions.

Thanks for your help,

Regards,


Solution

  • "Macintosh HD>Users>your username>.Trash" It is hidden to finder but you can locate it in the terminal or otherwise. From then on it is a normal folder and you can do whatever functions you would like to it. Could be done like such

    NSError *error=nil;
    NSString *path=[NSHomeDirectory() stringByAppendingPathComponent:@".Trash"];
    NSArray *folderList=[[NSFileManager defaultManager] contentsOfDirectoryAtPath:path error:&error];