(void)createfolder:(nsstring *)foldername { nsstring *imagedir = [nsstring stringwithformat:@"%@/documents/%@", nshomedirectory(),foldername]; nslog(@"homedir: %@",imagedir); bool isdir = no; nsfilemanager *filemanager = [nsfilemanager defaultmanager]; bool existed = [filemanager fileexistsatpath:imagedir isdirectory:&isdir]; if ( !(isdir == yes && existed == yes) ) { [filemanager createdirectoryatpath:imagedir withintermediatedirectories:yes attributes:nil error:nil]; } } (void)deletefolder:(nsstring *)foldername { nsstring *imagedir = [nsstring stringwithformat:@"%@/documents/%@", nshomedirectory(),foldername]; nslog(@"homedir: %@",imagedir); nsfilemanager *filemanager = [nsfilemanager defaultmanager]; [filemanager removeitematpath:imagedir error:nil]; } (void)changefoldername:(nsstring *)foldername beforename:(nsstring *)beforename { nsfilemanager *fm = [nsfilemanager defaultmanager]; nsstring *beforefolder = [nsstring stringwithformat:@"%@/documents/%@", nshomedirectory(),beforename]; nsstring *afterfolder = [nsstring stringwithformat:@"%@/documents/%@", nshomedirectory(),foldername]; [fm createdirectoryatpath:afterfolder withintermediatedirectories:yes attributes:nil error:nil]; nsdirectoryenumerator *direnum = [fm enumeratoratpath:beforefolder]; nsstring *path; while ((path = [direnum nextobject]) != nil) { [fm moveitematpath:[nsstring stringwithformat:@"%@/%@",beforefolder,path] topath:[nsstring stringwithformat:@"%@/%@",afterfolder,path] error:null]; } [fm removeitematpath:beforefolder error:nil]; }
用户登录
还没有账号?立即注册
用户注册
投稿取消
文章分类: |
|
还能输入300字
上传中....