Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

trey5498

macrumors regular
Original poster
Jun 16, 2008
191
0
How do I get the current working directory of the application? in the command or shell line it is "./test.txt" However setting that to a path doesnt seem to work.

I have seen:

GetCurrentDirectory, but I can't seem to track that one down either. Any ideas?
 
On most unix systems you can get the environment variable PWD with getenv. This may also work, but I am not familiar with how it behaves:
Code:
NSString *myPath = [[NSBundle mainBundle] bundlePath];

Lee
 
On most unix systems you can get the environment variable PWD with getenv. This may also work, but I am not familiar with how it behaves:
Code:
NSString *myPath = [[NSBundle mainBundle] bundlePath];

Lee

How to obtain just the path and not the file name?
 
Code:
NSString *myPath = [[NSBundle mainBundle] bundlePath];

got the path in one line where getcwd wanted to do it in like 3 and I kept getting errors. I am trying to do it in as much cocoa as I can.
 
Can't you use

Code:
NSString *curDir = [[NSFileManager defaultManager] currentDirectoryPath];

? Or is that not the same thing?
 
Not working in my code?????

Hi Guys i tried both
Code:
NSString *myPath = [[NSBundle mainBundle] bundlePath];
&
NSString *curDir = [[NSFileManager defaultManager] currentDirectoryPath];
Earlier due to some mistakes these were not getting work but now working. Thanks to all.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.