详解IOS中文件路径判断是文件还是文件夹
方法1
+ (BOOL)isDirectory:(NSString *)filePath { BOOL isDirectory = NO; [[NSFileManager defaultManager] fileExistsAtPath:filePath isDirectory:&isDirectory]; return isDirectory; }
方法2
+ (BOOL)isDirectory:(NSString *)filePath { NSNumber *isDirectory; NSURL *fileUrl = [NSURL fileURLWithPath:filePath]; [fileUrl getResourceValue:&isDirectory forKey:NSURLIsDirectoryKey error:nil]; return isDirectory.boolValue; }
如有疑问请留言或者到本站社区交流讨论,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!