码迷,mamicode.com
首页 > 移动开发 > 详细

读取IOS的相应路径

时间:2014-06-20 21:41:56      阅读:250      评论:0      收藏:0      [点我收藏+]

标签:class   文件   string   os   name   for   

//    IOS相应路径

    NSString* bundlePath = [[NSBundle mainBundle] bundlePath];

    NSLog(@"bundlePath = %@", bundlePath);

//    documents

    NSString* documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory, NSUserDomainMask, YES) lastObject];

    NSLog(@"documentsDirectory = %@", documentsDirectory);

    //    Library

    NSString* libraryDirectory = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) lastObject];

    NSLog(@"libraryDirectory = %@", libraryDirectory);

    //    Cache

    NSString* cacheDirectory = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject];

    NSLog(@"cacheDirectory = %@", cacheDirectory);

 

    //    读取路径下所有文件

    NSFileManager* fm = [NSFileManager defaultManager];

    NSArray* array = [fm contentsOfDirectoryAtPath:MusicPath error:nil];

    NSLog(@"%@", array);

    

//所有文件和文件夹

    NSDirectoryEnumerator* dirEnum = [fm enumeratorAtPath:MusicPath];

    NSLog(@"dirEnum = %@", dirEnum);

 

    for (NSString* fileName in dirEnum) {

        NSLog(@"%@", fileName);

    }

读取IOS的相应路径,布布扣,bubuko.com

读取IOS的相应路径

标签:class   文件   string   os   name   for   

原文地址:http://www.cnblogs.com/guanliyang/p/3796018.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!