PDA

View Full Version : Deleting a non-empty directory




swimlikehell
Apr 15, 2008, 10:11 AM
Hello,

I am trying to create some code that will delete a non-empty directory so that a user can replace an application in a specific folder on their computer. I have tried using FSDeleteObject but that only would on empty directories. Any help would be much appreciated, thanks.



kainjow
Apr 15, 2008, 10:17 AM
You're using Carbon right?

swimlikehell
Apr 15, 2008, 10:24 AM
Yes I am, but I can use cocoa if you know how to do it with that.

kainjow
Apr 15, 2008, 10:28 AM
I tried looking for a Carbon solution but couldn't find anything. I'm sure there is some code snippet out there though. You could also just try using standard POSIX functions.

But in Cocoa it's as simple as:

[[NSFileManager defaultManager] removeFileAtPath:somePath handler:nil];

:)