robie strukturę folderów w folderze moim zasobów jak ... Zasób => MyData => S1 następnie w S1 => Name.png, data.pptJak uzyskać listę folderów i plików z folderu zasobów w telefonie iPhone?
Teraz chcę uzyskać wszystkie katalogi i nazwy plików . Tutaj nazwa MyData będzie tylko statyczna, inne mogą się zmieniać. Jak mogę dodać S1, S2, S3 i liczbę plików w tym. Jak odczytać te treści za pomocą C? Próbowałem poniżej kodu.
NSString *bundlePathName = [[NSBundle mainBundle] bundlePath];
NSString *dataPathName = [bundlePathName stringByAppendingPathComponent:@"Resources"];
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath:dataPathName]) {
NSLog(@"%@ exists", dataPathName);
BOOL isDir = NO;
[fileManager fileExistsAtPath:dataPathName isDirectory:(&isDir)];
if (isDir == YES) {
NSLog(@"%@ is a directory", dataPathName);
NSArray *contents;
contents = [fileManager contentsOfDirectoryAtPath:dataPathName error:nil];
for (NSString *entity in contents) {
NSLog(@"%@ is within", entity);
}
} else {
NSLog(@"%@ is not a directory", dataPathName);
}
} else {
NSLog(@"%@ does not exist", dataPathName);
}
Dzięki