获取沙盒文件夹路径

来源:互联网 发布:软件开发平台 编辑:程序博客网 时间:2024/06/11 12:58

有两种获取沙盒路径的方法:

//第一种方法//(1)获取主目录NSString *homePath = NSHomeDirectory();//(2)拼接路径NSString *documentsPath  = [homePath stringByAppendingPathComponent:@"Documents"];NSLog(@"Documents路径:%@\n",documentsPath);//第二种方法 NSArray *documentArray =  NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);NSString *documentsPath = [documentArray objectAtIndex:0];NSLog(@"Documents路径:%@\n",documentsPath);    NSArray *libraryArray = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);NSString *libraryPath = [libraryArray objectAtIndex:0];NSLog(@"Library路径:%@\n",libraryPath);NSString *cachesPath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0];NSLog(@"Library下的Caches路径:%@\n",cachesPath);NSString *tmpPath = NSTemporaryDirectory();NSLog(@"tmp路径:%@\n",tmpPath);
0 0