Vector<string> Getallfilenamesindirectory () {
Ref TO:HTTP://STACKOVERFLOW.COM/QUESTIONS/5749488/ITERATING-THROUGH-FILES-IN-A-FOLDER-WITH-NESTED-FOLDERS-COCOA
Nsfilemanager *filemanager = [[[[Nsfilemanager alloc] init] autorelease];
Nsurl *directoryurl = [Nsurl urlwithstring:@ "Toolkitres/model"]; URL pointing to the directory want to browse
Nsarray *keys = [Nsarray Arraywithobject:nsurlisdirectorykey];
Nsdirectoryenumerator *enumerator = [FileManager
Enumeratoraturl:directoryurl
Includingpropertiesforkeys:keys
options:0
errorhandler:^ (Nsurl *url, Nserror *error) {
Handle the error.
Return YES If the enumeration should continue after the error.
return YES;
}];
Vector<string> fullpathlist;
For (Nsurl *url in enumerator) {
Nserror *error;
NSNumber *isdirectory = nil;
if (! [url getresourcevalue:&isdirectory forkey:nsurlisdirectorykey error:&error]) {
Handle error
}
else if (! [Isdirectory Boolvalue]) {
No error and it ' s not a directory; Do something with the file
NSString *str_ns=[url absolutestring];
NSLog (@ "%@", Str_ns);
String Fullpath=[str_ns cstringusingencoding:nsasciistringencoding];
Fullpathlist.push_back (FullPath);
}
}
return fullpathlist;
}
Object-c get all the files under the catalogue (including subdirectories)