Reading and Writing files in IOS

Source: Internet
Author: User

In iOS, Apple has encapsulated a class and opened the corresponding IPA. The corresponding class is nsfilemanager and the file management class.

Instantiation:

 
Nsfilemanager * manage = [nsfilemanager defaultmanager];

Create a file directory

 
[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:

 
Bool iswrite = [_ DATA writetofile: filepath atomically: Yes];

Returns the result and determines whether the operation is successful.

Copy an object:

 
-(Bool) copyitematpath :( nsstring *) srcpath topath :( nsstring *) dstpath error :( nserror **) Error ns_available (10_5, 2_0 );

Transfer:

-(Bool) moveitematpath :( nsstring *) srcpath topath :( nsstring *) dstpath error :( nserror **) Error ns_available (10_5, 2_0 );

Delete:

 
-(Bool) removeitematpath :( nsstring *) path error :( nserror **) Error ns_available (10_5, 2_0 );

Whether the file exists:

 
-(Bool) fileexistsatpath :( nsstring *) path;

Whether the file can be read:

 
-(Bool) isreadablefileatpath :( nsstring *) path;

.... , A series of common uses.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.