Hi all,
In the past few years the question of how to list files in a (documents) folder has been popping every now and then. While in older versions of iOS it was apparently possible to achieve this through os.execute( “ls” ) call, it is no longer possible.
In one of the forum posts dated from last October, Danny said he will work on a one-hour workaround, but nothing came out of it?
Listing files in a folder is a very basic requirement for a broad range of apps where we don’t have control over the files that users save in Documents folder (through iTunes sharing).
Is there a way we can have this simple functionality, that in ObjectiveC would be accomplished by something like:
int Count;
NSString \*path;
NSArray \*paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
path = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"SomeDirectoryName"];
NSArray \*directoryContent = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:path error:NULL];
for (Count = 0; Count \< (int)[directoryContent count]; Count++)
{
NSLog(@"File %d: %@", (Count + 1), [directoryContent objectAtIndex:Count]);
}
So is there a way that we can have a quick wrapper around this function, or -well- any other way we can access this critical information ?
I know this might look like a non-cross-platform hack and it would require serious thinking where to put such functionality in the current API Matrix, but it is a shame that a requirement so basic and so simple to resolve remain open.
Thanks
N [import]uid: 80100 topic_id: 22546 reply_id: 322546[/import]