[ios测试版描述文件]详解IOS中文件路径判断是文件还是文件夹

更新时间:2021-08-20    来源:ios    手机版     字体:

【www.bbyears.com--ios】

详解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; 
} 

本文来源:http://www.bbyears.com/shoujikaifa/137198.html

热门标签

更多>>

本类排行