如何判断Documents下的指定目录是否存在?FileManager中的 FileExistAtPath 返回的结果始终是-1我查了一下也没找到对Dir的相关接口 特在此请教,望解答.

解决方案 »

  1.   

    NSString *documentPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
     NSString *realPath = [documentPath stringByAppendingPathComponent:@"你的文件名"];
     NSFileManager *fileManager = [NSFileManager defaultManager];
     if ([fileManager fileExistsAtPath:realPath])
     {NSLog(@"存在这个文件");}
      

  2.   

    都放在沙箱的document目录中,放文件吧,别目录折腾了。
      

  3.   

    fileExistsAtPath:isDirectory:Returns a Boolean value that indicates whether a file or directory exists at a specified path.- (BOOL)fileExistsAtPath:(NSString *)path isDirectory:(BOOL *)isDirectory文档里有