IOS Create a folder, delete a folder, rename an action on a folder by Wusheying
+ (void) CreateFolder: (NSString*) FolderName {
NSString*imagedir = [NSStringstringWithFormat:@ "%@/documents/%@",nshomedirectory(), FolderName];
NSLog(@ "Homedir:%@", Imagedir);
BOOLIsdir =NO;
Nsfilemanager*filemanager = [NsfilemanagerDefaultmanager];
BOOLexisted = [FileManagerFileexistsatpath: Imagedirisdirectory:&isdir];
if ( !( Isdir = =YES&& existed = =YES) )
{
[FileManagerCreatedirectoryatpath: Imagedirwithintermediatedirectories:YESattributes:NilError:Nil];
}
}
+ (void) DeleteFolder: (NSString*) FolderName {
NSString*imagedir = [NSStringstringWithFormat:@ "%@/documents/%@",nshomedirectory(), FolderName];
NSLog(@ "Homedir:%@", Imagedir);
Nsfilemanager*filemanager = [NsfilemanagerDefaultmanager];
[FileManagerremoveItemAtPath: ImagedirError:Nil];
}
+ (void) Changefoldername: (NSString*) FolderName beforename: (NSString*) Beforename {
Nsfilemanager*FM = [NsfilemanagerDefaultmanager];
NSString*beforefolder = [NSStringstringWithFormat:@ "%@/documents/%@",nshomedirectory(), Beforename];
NSString*afterfolder = [NSStringstringWithFormat:@ "%@/documents/%@",nshomedirectory(), FolderName];
[FMCreatedirectoryatpath: Afterfolderwithintermediatedirectories:YESattributes:NilError:Nil];
Nsdirectoryenumerator*direnum = [FMEnumeratoratpath: Beforefolder];
NSString*path;
while(Path = [DirenumNextobject]) !=Nil) {
[FMMoveitematpath:[NSStringstringWithFormat:@"%@/%@", Beforefolder,path]
Topath:[NSStringstringWithFormat:@"%@/%@", Afterfolder,path]
Error:NULL];
}
[FMremoveItemAtPath: BeforefolderError:Nil];}
IOS Create folder, delete folder, rename folder action