iOS開發(fā)之file列表查看
作者:佚名
本文為大家介紹了iOS開發(fā)中的file列表查看,新手所寫的程序分享給大家,希望對51CTO的各位網(wǎng)友有所幫助,如果有什么意見歡迎交流。
哈哈,我是新手,下面為大家介紹一下在iOS開發(fā)中的如何實現(xiàn)file列表查看。
查看根目錄下的文件列表
- NSArray *leveList=
- [[[NSFileManager alloc]init] contentsOfDirectoryAtPath: [NSHomeDirectory() stringByAppendingPathComponent:@""] error:nil];
- for (NSString *str in leveList) {
- NSLog(@"levelList:%@",str);
- }
- NSLog(@"count:%d",[leveList count] );
文件列表結(jié)果如下:
- 2013-06-14 16:18:14.513 helloword[853:c07] levelList:Documents
- 2013-06-14 16:18:14.533 helloword[853:c07] levelList:helloword.app
- 2013-06-14 16:18:14.534 helloword[853:c07] levelList:Library
- 2013-06-14 16:18:14.535 helloword[853:c07] levelList:tmp
- 2013-06-14 16:18:14.537 helloword[853:c07] count:4
查看Library文件列表
- NSArray *leveList=
- [[[NSFileManager alloc]init] contentsOfDirectoryAtPath: [NSHomeDirectory() stringByAppendingPathComponent:@"Library"] error:nil];
- for (NSString *str in leveList) {
- NSLog(@"Library:%@",str);
- }
- NSLog(@"count:%d",[leveList count] );
結(jié)果如下:
- 2013-06-14 16:26:49.475 helloword[1040:c07] Library:Caches
- 2013-06-14 16:26:49.478 helloword[1040:c07] Library:Preferences
- 2013-06-14 16:26:49.480 helloword[1040:c07] count:2
責任編輯:閆佳明
來源:
apkbus