I'm creating a little program to copy the Domain file for iWeb over to a USB stick or external harddrive or such. The program is meant to be run from that USB stick or external harddrive, and then create a directory where the application is run from. E.g. the application is run from ~/Documents, the application should create a folder at ~/Documents/(account name)'s website, and then copy the Domain file to that folder. But when I try to run the application from a USB stick, it creates a folder under /, called /(account name)'s website. How do I fix this?
A:
NSBundle
has an instance method called bundlePath
which will almost get you what you want.
NSString *bundleParentPath = [[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent];
This should return the directory that the application is being run from.
dreamlax
2010-08-26 08:10:44
No, it'll return the path to the bundle.
Peter Hosey
2010-08-26 08:20:24
@Peter: Whoops! Too true.
dreamlax
2010-08-26 11:45:58