1、 iphone的文件管理器是NSFileManager类提供的一个单例。它可以列出文件夹的内容,以确定找到那些文件,然后执行基本的文件系统任务。下面的代码片段从两个文件夹取出一个文件列表。首先它查找了沙盒的Documents文件夹,然后在应用程序束中进行查找。
NSFileManager *fm = [NSFileManager defaultManaer];
//list the files in the sandox Documents folder
NSString *path =[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
nslog(@"%@",[fm directoryContentsAtPath:path]);
//list the files in the appication bundle
path =[[nsboudle mainbundle] bundlePath]
nslog(@"",[fm directoryContentsAtpath:path]);
2、返回应用程序的Default.png图片的路径
NSBundle *mb = [NSBundle mainBundle];
nslog(@"%@",[mb pathForResource:@"Default" ofType:@"png"]);