My folder contains only one sub-folder, and I don't know sub-folder's name. This sub-folder contains a html file, and once again I don't know the html file's name.
My question is how I can get full path of this file by using
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *folderPath = [documentsDirectory stringByAppendingPathComponent:filename]; //- access sub-folder? //- access html file?
EDITED:
I wrote a method to return the only one sub-folder as follow:
+ (NSString*) get1stSubFolder:(NSString*)folder { NSDirectoryEnumerator *directoryEnumerator = [[NSFileManager defaultManager] enumeratorAtPath:folder]; //- no recursive [directoryEnumerator skipDescendents]; NSString* file; while (file = [directoryEnumerator nextObject]) { BOOL isDirectory = NO; BOOL subFileExists = [[NSFileManager defaultManager] fileExistsAtPath:file isDirectory:&isDirectory]; if (subFileExists && !isDirectory) { return file; } } return nil; }
I always get nil as result. Do you know where was I wrong at?