In ios, Apple has encapsulated a class and opened the corresponding IPA. The corresponding class is NSFileManager and the file management class.
Instantiation:
[Plain]
NSFileManager * manage = [NSFileManager defaultManager];
NSFileManager * manage = [NSFileManager defaultManager];
Create a file directory
[Plain]
[Manage createDirectoryAtPath: direcatorypath withIntermediateDirectories: YES attributes: nil error: nil];
[Manage createDirectoryAtPath: direcatorypath withIntermediateDirectories: YES attributes: nil error: nil];
Returns the bool type and determines whether the bool type is successfully created.
If you write data to a file, such as NSData, you can:
[Plain]
BOOL isWrite = [_ data writeToFile: filepath atomically: YES];
BOOL isWrite = [_ data writeToFile: filepath atomically: YES];
Returns the result and determines whether the operation is successful.
Copy an object:
[Plain]
-(BOOL) copyItemAtPath :( NSString *) srcPath toPath :( NSString *) dstPath error :( NSError **) error NS_AVAILABLE (10_5, 2_0 );
-(BOOL) copyItemAtPath :( NSString *) srcPath toPath :( NSString *) dstPath error :( NSError **) error NS_AVAILABLE (10_5, 2_0 );
Transfer:
[Plain]
-(BOOL) moveItemAtPath :( NSString *) srcPath toPath :( NSString *) dstPath error :( NSError **) error NS_AVAILABLE (10_5, 2_0 );
-(BOOL) moveItemAtPath :( NSString *) srcPath toPath :( NSString *) dstPath error :( NSError **) error NS_AVAILABLE (10_5, 2_0 );
Delete:
[Plain]
-(BOOL) removeItemAtPath :( NSString *) path error :( NSError **) error NS_AVAILABLE (10_5, 2_0 );
-(BOOL) removeItemAtPath :( NSString *) path error :( NSError **) error NS_AVAILABLE (10_5, 2_0 );
Whether the file exists:
[Plain]
-(BOOL) fileExistsAtPath :( NSString *) path;
-(BOOL) fileExistsAtPath :( NSString *) path;
Whether the file can be read:
[Plain]
-(BOOL) isReadableFileAtPath :( NSString *) path;
-(BOOL) isReadableFileAtPath :( NSString *) path;