• 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: Rolf <email@hidden>
  • Date: Mon, 23 Jun 2003 20:04:31 +0200

Hi,

Try using the following:

NSFileManager * mgr = [NSFileManager defaultManager];
NSBundle * bundle = [NSBundle mainBundle];
sPath = [bundle bundlePath];

The above path includes the name (actually "path" since it is a bundle) of application. To remove that part + add your own filename use the following:


sMyExternalFile = [[sPath stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"externalfile.xyz"];


/Rolf

23.06.2003 19:57:25, skrev James Ludtke <email@hidden>:

>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?
>_______________________________________________
>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.
_______________________________________________
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: currentDirectoryPath does not work
  • Next by Date: Re: currentDirectoryPath does not work
  • Previous by thread: currentDirectoryPath does not work
  • Next by thread: Re: currentDirectoryPath does not work
  • Index(es):
    • Date
    • Thread