Re: currentDirectoryPath does not work
Re: currentDirectoryPath does not work
- Subject: Re: currentDirectoryPath does not work
- From: Douglas Davidson <email@hidden>
- Date: Mon, 23 Jun 2003 12:45:42 -0700
On Monday, June 23, 2003, at 10:57 AM, James Ludtke wrote:
I am trying to read and write from my application to a file that is in
the
same folder as my application. because I can not be certain where a
user may
put the folder, I do not know the absolute path. The following code
works
when I run my application from within the Project Builder, but fails
when I
run the compiled application. The compiled application reads from and
writes
to root. This includes the application in the build folder.
You can never assume that the current working directory has any
particular value, unless you set it yourself. That's how it has always
been on Unix.
NSBundle knows where your application is. [[NSBundle mainBundle]
bundlePath] will tell you, and from there you remove the last path
component to get to the parent directory.
Before you start trying to write to anything in the same directory as
your app, you had better make sure it is writable. Some users won't be
able to write to /Applications; in addition, your application might
well be on a server, or on a CD, or somewhere else that isn't writable.
~/Library/Application Support is a good location for files your app
might need to write, or ~/Documents if they are intended as
user-visible documents.
Douglas Davidson
_______________________________________________
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.