-(float)filesizefordir:(nsstring*)path//计算文件夹下文件的总大小 { nsfilemanager *filemanager = [[nsfilemanager alloc] init]; float size =0; nsarray* array = [filemanager contentsofdirectoryatpath:path error:nil]; for(int i = 0; i<[array count]; i ) { nsstring *fullpath = [path stringbyappendingpathcomponent:[array objectatindex:i]]; bool isdir; if ( !([filemanager fileexistsatpath:fullpath isdirectory:&isdir] && isdir) ) { nsdictionary *fileattributedic=[filemanager attributesofitematpath:fullpath error:nil]; size = fileattributedic.filesize/ 1024.0/1024.0; } else { [self filesizefordir:fullpath]; } } han = han size; return size; }
用户登录
还没有账号?立即注册
用户注册
投稿取消
文章分类: |
|
还能输入300字
上传中....