//单例类,相当于一个文件管理者
NSFileManager *fileManager = [NSFileManager defaultManager];
//递归获取指定文件路径下的所有文件或文件夹
- (NSArray *)subpathsAtPath:(NSString *)path;
//读取文件内容
- (NSData *)contentsAtPath:(NSString *)path;
//创建文件
- (BOOL)createFileAtPath:(NSString *)path contents:
(NSData *)data attributes:(NSDictionary *)attr;
//复制文件
- (BOOL)copyItemAtPath:(NSString *)srcPath toPath:
(NSString *)dstPath error:(NSError **)error
//移动文件
- (BOOL)moveItemAtPath:(NSString *)srcPath toPath: (NSString *)dstPath error:(NSError **)error
//文件是否存在
- (BOOL)fileExistsAtPath:(NSString *)path;
//文件或文件夹是否存在,并判断是否为文件夹
- (BOOL)fileExistsAtPath:(NSString *)path
isDirectory:(BOOL *)isDirectory;
//只读
- (BOOL)isReadableFileAtPath:(NSString *)path;
//只写
- (BOOL)isWritableFileAtPath:(NSString *)path;
NSFileManager 类 文件的管理
最新推荐文章于 2021-08-12 17:27:14 发布