• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: currentDirectoryPath does not work
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: currentDirectoryPath does not work


  • Subject: Re: currentDirectoryPath does not work
  • From: Fritz Anderson <email@hidden>
  • Date: Mon, 23 Jun 2003 13:19:18 -0500

Not a bug; the current directory in a Finder-launched application is "/". The "current working directory," is a shorthand construct for the convenience of a user working at a terminal; the Finder, a multi-window UI that displays several directory contexts at once, doesn't intelligibly have a single working directory.

NSBundle provides the canonical way to, well, bundle files with an application. See, for instance, [[NSBundle mainBundle] executablePath].

-- F

On Monday, June 23, 2003, at 12:57 PM, 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.

myPath = [[NSFileManager defaultManager] currentDirectoryPath];
myFile = @"dsf.txt";
myFilePath = [myPath stringByAppendingPathComponent: myFile];
myStatusString = [NSString stringWithContentsOfFile: myFilePath];

I also tried the Unix relative path method, e.g,

myPath = @"./"

This also works from within Project Builder but again fails from the
compiled application.

Is this a bug in Cocoa, or what am I doing wrong?

--
Fritz Anderson - Consulting Programmer - Chicago, IL
Mail: <email@hidden>
Risumi: <http://resume.manoverboard.org>
_______________________________________________
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.

References: 
 >currentDirectoryPath does not work (From: James Ludtke <email@hidden>)

  • Prev by Date: Re: currentDirectoryPath does not work
  • Next by Date: RE: currentDirectoryPath does not work
  • Previous by thread: Re: currentDirectoryPath does not work
  • Next by thread: RE: currentDirectoryPath does not work
  • Index(es):
    • Date
    • Thread