NSURL* suppurl = [manager URLForDirectory:NSApplicationSupportDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:nil];
NSString *path = [suppurl path];
NSLog(@" Path %@",path);
NSString* myfolder = [path stringByAppendingPathComponent:@"MyFolder"];
NSDirectoryEnumerator* myFolderDir = [manager enumeratorAtPath:myfolder];
for (NSString* file in myFolderDir)
{
NSLog(@" file %@",file);
NSString *getImagePath = [path stringByAppendingPathComponent:[NSString stringWithFormat:@"%@",file]];
BOOL exists = [[NSFileManager defaultManager] fileExistsAtPath:getImagePath];
NSLog(@" image path %@",getImagePath);
if (exists)
{
NSLog(@" exists");
}
The first NSLog(@" file %@",file); successfully logs the file name… but the BOOL exists doesn’t .
What could be the problem?
You are enumerating files in
myFolderDir, but then you are trying to verify if an equally-named file exists inpath. Replace with:Also, note that you don’t need to do this:
..
filealready being anNSString.In case you’re trying to enumerate images in that folder, consider testing the file extension: