How can I get url path for a particular directory inside Document Directory.
like Document/Art/
My code
- (NSURL *)localRoot {
Application.StartupPath;
is used to find your path where your application is being started, if that is what you mean.
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *yourArtPath = [documentsDirectory stringByAppendingPathComponent:@"/Art"];
Based on above answer here is an simple methode that returns, path for given directory:
+ (NSString *) pathFor : (NSString *) directoryName{
return [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:directoryName];
}
You need to implement it in ClassName.m
and call as:
NSString *pathForDirectory = [ClassName pathFor:dirName]; //@"Art" in your case
Use this
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *appFile_a = [documentsDirectory stringByAppendingPathComponent:@"/Art"];