Re: Creating an Application Support folder
Re: Creating an Application Support folder
- Subject: Re: Creating an Application Support folder
- From: Gideon King <email@hidden>
- Date: Fri, 12 Feb 2010 14:17:23 +1000
Hi Paul
Firstly, are you using the
NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
function to find the application support folder?
That would get you the base path, then you can use the
stringByAppendingPathComponent:
method to add your folder name, then
BOOL isDirectory = NO;
BOOL exists = [[NSFileManager defaultManager] fileExistsAtPath:errorReporterPath isDirectory:&isDirectory];
and then check whether it exists, and whether it is a directory.
Then you can use methods like:
BOOL created = [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:&error];
to create the necessary folders. Hope this helps.
Gideon
On 11/02/2010, at 1:44 PM, Paul Johnson wrote:
> I'm trying to find a best way to create the Application Support
> folder. I'm rather new at Cocoa so it's taking me a while to do even
> this simple thing. I'm also interested in ensuring my application can
> be localized easily.
>
> I have a function "- (NSString *)applicationSupportFolder" that
> returns the desired folder name, properly localized. I call this
> function and then use NSFileManager to check for the existence of the
> folder. Because there can be a file (NOT a folder) already bearing the
> folder name, I need to handle that possibility. Everything I've found
> on the internet just ignores this case.
>
> Can anyone recommend what I should do?
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden