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