File Operation Nsmanager

Source: Internet
Author: User

1 operations on the file itself
Nsmanager

 Create a singleton File Manager Object Nsfilemanager *fm=[nsfilemanager Defaultmanager];                                            Light traverse//view files in the specified directory put the names of the obtained files and folders into the array the return value is the address of the array Nseroor *error=nil;    The address of the pointer nsarray *array= [FM contentsofdirectoryatpath: (file path) error:&error];        if (Error) {NSLog (@ "@", error);    Exit (-1);        } NSLog (@ "%@", array);    Deep traversal ARRAY=[FM subpathsofdirectoryatpath: (file path) error:&error];        if (Error) {NSLog (@ "@", error);    Exit (-1);        } NSLog (@ "%@", array); Create directory [FM createdirectoryatpath:[nsstring stringwithformat:@ "%@/middle/dir", path name] Withintermediatedirectories: (    Whether there is an intermediate path, if no will be error) Attributes:nil Error:&error];        if (Error) {NSLog (@ "@", error);    Exit (-1); }//create file [FM createfileatpath:[nsstring stringwithformat:@ "%@/middle/dir/file", path name] Contents: (NSData *) file contents (    You can make it nil without first writing it attributes: File attributes (nil means using default attributes)]; Deletion of files (files, folders, directories can be deleted) [FM REMOVEITEMATPATh:[nsstring stringwithformat:@ "%@/middle", path name] error:&error];        if (Error) {NSLog (@ "@", error);    Exit (-1); }//Copy and delete same file and directory [FM copyitematpath:[nsstring stringwithformat:@ "%@/dir", path name] (path of original file) topath:[@ "%@/dir1", path name]     (Path of the generated file) Error:&error];        if (Error) {NSLog (@ "@", error);    Exit (-1); }//Move file (CUT) [FM moveitematpath:[nsstring stringwithformat:@ "%@/dir", path name] (path of the original file) topath:[@ "%@/dir2", path name] (generate     The path of the file) Error:&error];        if (Error) {NSLog (@ "@", error);    Exit (-1); }

  

File Operation Nsmanager

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.