路径操作 沙箱完整路径 tmp完整路径 判断路径

获取沙箱目录的完整路径

//获取沙箱目录的完整路径
//uuid.plist
NSArray *myPaths = NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory, NSUserDomainMask, YES);
NSString *myDocPath = [myPaths objectAtIndex:0];

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

NSString *filename = [myDocPath stringByAppendingPathComponent:@"uuid.plist"];
NSLog(@"filename = %@",filename);

获取tmp目录

//获取tmp目录
NSString *tmpPath = NSTemporaryDirectory();
NSString *tmpfilename = [tmpPath stringByAppendingPathComponent:@"uuid.plist"];
NSLog(@"tmpfilename = %@",tmpfilename);

判断路径是否存在

//判断路径是否存在
if([[NSFileManager defaultManager] fileExistsAtPath:filename])
{
    NSLog(@"文件存在");
}
else
{
    NSLog(@"文件不存在");
}

comments powered by Disqus