3

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?

2 Answers 2

4

If you want the current working directory of your app then use NSFileManager's currentDirectoryPath.

NSString *currentPath = [[NSFileManager defaultManager] currentDirectoryPath];
Sign up to request clarification or add additional context in comments.

Comments

1

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.

1 Comment

No, it'll return the path to the bundle.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.