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
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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With