1

有没有一种快速的方法来为 NSHomeDirectory 中的特定文件夹吐出目录列表?我正在使用ASIHTTPRequest中的一个示例,该示例通过以下方式下载图像:

[request setDownloadDestinationPath:[[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"totallyhotmilf.jpg"]];

我想列出 Documents 文件夹中的文件,以查看实际下载的内容以用于调试目的。谢谢您的帮助。

4

1 回答 1

3

多亏了这个页面,找到了我的问题的答案。这将为您提供一个不错的文件列表:

// Create file manager
NSError *error;
NSFileManager *fileMgr = [NSFileManager defaultManager];

// Point to Document directory
NSString *documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];

// Write out the contents of home directory to console
NSLog(@"Documents directory: %@", [fileMgr contentsOfDirectoryAtPath:documentsDirectory error:&error]);
于 2010-11-03T16:10:53.913 回答