Listing Files In A Folder, Maybe Using NSFileManager ?

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]

While I feel that I would want this basic functionality, in thinking about it, I’m not sure that we **NEED** it.

Consider that:

a. Any file you create via code you know about and can keep track of.
b. Any file you download, you have to specify the filename for network.download to save to, so again you know the name and can keep track of it.

You’re responsible for what you create and other processes do not have the ability to write there, so there should never be any unknown files.

[import]uid: 19626 topic_id: 22546 reply_id: 89898[/import]

Hi Rob,
Thanks for your suggestions, I am aware of user scenarios where application itself creates (or downloads) and saves the files.
However, in a case where you’d want user to add files, and adding files to app through iTunes is by far the most user-friendly method, we are left with no option to track the content of documents folder.
I know alternatively there is a way to make a browser interface and upload files over WiFi, but for a typical user ( and trust me, none of us in this forum is a typical user) its a put off.
Not to say that in order to add a large number of files a web interface ( with one-by-one upload ) over WiFi connection becomes both a user experience annoyance as well as bottleneck.

There is a wide range of types of applications that I can think of that could benefit from better control over files.

[import]uid: 80100 topic_id: 22546 reply_id: 89901[/import]

I am trying to work something out regarding this, and am speaking with the team. I can’t offer any timelines or promises at this stage but I can tell you I am trying. [import]uid: 84637 topic_id: 22546 reply_id: 90006[/import]

+1
and tracking this thread. [import]uid: 110373 topic_id: 22546 reply_id: 93668[/import]

+1
i want to be able to do this also :slight_smile: [import]uid: 89663 topic_id: 22546 reply_id: 95073[/import]