获取iOS各种文件路径

//得到Document目录:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
 
//得到temp临时目录:
NSString *tempPath = NSTemporaryDirectory();
  
//得到目录上的文件地址:
NSString *文件地址 = [目录地址 stringByAppendingPathComponent:@"文件名.扩展名"];
 
 
//Document

 NSArray *paths1 = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

    NSString *thePath1 = [paths1 objectAtIndex:0];

    NSLog(@"%@",thePath1);

    

//沙盒

    NSArray *paths2 = NSSearchPathForDirectoriesInDomains(NSCachesDirectory,NSUserDomainMask, YES);

    NSString *cachesDirectory2 = [paths2 objectAtIndex:0];

    NSLog(@"%@",cachesDirectory2);

//项目中    

    NSString *paths = [[NSBundle mainBundle] resourcePath];

    NSLog(@"%@",paths);

    NSString *xmlFile = [paths stringByAppendingPathComponent:@"PCD.db"];

posted on 2014-08-15 15:11  &大飞  阅读(142)  评论(0)    收藏  举报

导航