Re: Newbie: Current Apps Directory
Re: Newbie: Current Apps Directory
- Subject: Re: Newbie: Current Apps Directory
- From: Craig Bakalian <email@hidden>
- Date: Tue, 15 Apr 2003 16:40:40 -0400
On Tuesday, April 15, 2003, at 03:31 PM,
email@hidden wrote:
>
I'm doing a quick little drag and drop utility that has template files
>
next to it that I need to read. I have things set up to be flexible
>
enough to change which template files to use, but as a default, I would
>
like it to read the ones that are right next to it. ( html files )
>
( worst comes to worst I'll set it up in a preference, and have to set
>
it up the first time I use it, but I'd rather not do anything extra,
>
since one can easily change it if the initial suggestion is not good )
>
-- which in my case it is.
Hi,
I had the same problem a day ago. This was the solution ->
-(void) someFunction
{
NSString *file;
NSFileManager *fileManager = [NSFileManager defaultManager];
NSDirectoryEnumerator *enumerator;
NSString *bun = [[NSBundle mainBundle] bundlePath];
NSString *p = [bun stringByAppendingPathComponent: @"/.."];
if([fileManager changeCurrentDirectoryPath: p])
{
enumerator = [fileManager enumeratorAtPath: [fileManager
currentDirectoryPath]];
while(nil != (file = [enumerator nextObject]))
{
}
}
}
The [[NSBundle mainBundle] bundlePath] gets the apps bundle path, the
@"/.." shoots the directory up.
The enumerator just chugs through all in the directory. You just need
to set the currentDirectoryPath before you use it. The name
currentDirectoryPath is misleading.
Craig Bakalian
www.eThinkingCap.com
_______________________________________________
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.