Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to search for directories ios

I want to know how to check if a directory exists in my application

for example: if I want to search if a folder exists in my application document

and how to create a new folder within it

best regards

like image 268
Ali Avatar asked Mar 02 '11 23:03

Ali


1 Answers

Checking for file existence:

+(BOOL)fileExistsAtAbsolutePath:(NSString*)filename {
    BOOL isDirectory;
    BOOL fileExistsAtPath = [[NSFileManager defaultManager] fileExistsAtPath:filename isDirectory:&isDirectory];

    return fileExistsAtPath && !isDirectory;
}

Checking for directory existence:

+(BOOL)directoryExistsAtAbsolutePath:(NSString*)filename {
    BOOL isDirectory;
    BOOL fileExistsAtPath = [[NSFileManager defaultManager] fileExistsAtPath:filename isDirectory:&isDirectory];

    return fileExistsAtPath && isDirectory;
}
like image 174
FreeAsInBeer Avatar answered Oct 19 '22 00:10

FreeAsInBeer