检查本地是否存在某个文件

Posted PengYunjing

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了检查本地是否存在某个文件相关的知识,希望对你有一定的参考价值。

// 取得沙盒目录
NSString *localPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
// 要检查的文件目录
NSString *filePath = [localPath  stringByAppendingPathComponent:@"abc.doc"];
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath:filePath]) {
    NSLog(@"文件abc.doc存在");
}
else {
    NSLog(@"文件abc.doc不存在");
}

 

以上是关于检查本地是否存在某个文件的主要内容,如果未能解决你的问题,请参考以下文章