iOS Intermediate article--nsfilemanager common method

Source: Internet
Author: User
Tags file copy

[FileManager isdeletablefileatpath:<# (NSString *) #>]; determine if a path can be deleted
[FileManager iswritablefileatpath:<# (NSString *) #>];?? Determine if a path is writable
[FileManager isreadablefileatpath:<# (NSString *) #>];?? Determine if a path is readable[FileManager fileexistsatpath:<# (NSString *) #>];???? Determine if a path exists? [FileManager fileexistsatpath:<# (NSString *) #> isdirectory:<# (BOOL *) #>]; Determine if a path is a folder?? BOOL needs to be passed in?? The returned value exists in bool? [FileManager attributesofitematpath:<# (NSString *) #> error:<# (nserror *__autoreleasing *) #>];?? Show more information

????

? get the files under the folder so file?? recursion

[filemanager Subpathsatpath:path];

?

[FileManager Subpathsofdirectoryatpath:path error:&error];

?

-(Nsarray *) Subpathsofdirectoryatpath: (NSString *) path error: (NSERROR * *) error;?? Non-recursive

??Get folder under folder[Filemanger contentsofdirectoryatpath:path Error:&err (error:nil)]

?


Create a folder

[FileManager Createdirectoryatpath:path withintermediatedirectories:no Attributes:nil Error:nil];


?creating a file requires a nsdata in advanceNsdata?*data = [str?datausingencoding:nsutf8stringencoding]; [filemanager?createfileatpath:[nsstring?stringwithformat:@ "%@/1.txt", Path]?contents:data?attributes:nil];?file copy?? Folder does not exist just fail and new folder is not created[FileManager copyitematpath:[nsstring stringwithformat:@ "%@/1.txt", Path] topath:[nsstring stringWithFormat:@ "% @/bbb/1.txt ", Path] error:nil];
file Move ?? Folder does not exist just fail and new folder is not created[filemanager?moveitematpath:[nsstring?stringwithformat:@ "%@/1.txt", Path]?topath:[nsstring?stringwithformat : @ "%@/ddd/1.txt", Path]?error:nil];
File Removal[FileManager removeitematpath:[nsstring stringwithformat:@ "%@/1.txt", Path] error:nil];

iOS Intermediate--nsfilemanager common methods

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.