• ios 得到目录大小 进率是1000


    - (CGFloat)folderSizeAtPath:(NSString *) folderPath
    {
        NSFileManager * manager = [NSFileManager defaultManager];
        
        if (![manager fileExistsAtPath:folderPath])
        {
          return 0;
        }
        
        NSEnumerator * childFilesEnumerator = [[manager subpathsAtPath:folderPath] objectEnumerator];
        NSString * fileName;

        long long folderSize = 0;
        
        while ((fileName = [childFilesEnumerator nextObject]) != nil)
        {
            
            NSString * fileAbsolutePath = [folderPath stringByAppendingPathComponent:fileName];
            
            float singleFileSize = 0.0;
            if ([manager fileExistsAtPath:fileAbsolutePath])
            {
                singleFileSize = [[manager attributesOfItemAtPath:fileAbsolutePath error:nil] fileSize];
                NSLog(@"singleFileSize %f",singleFileSize);
            }
            folderSize += singleFileSize;
        
        }
        NSLog(@"count file size %f",folderSize/1000.0);
        return folderSize/1000.0;
        

    }


    调用 :


        NSString * filePath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:[NSString stringWithFormat:@"/%@",@"TencentOpenApi_IOS_Bundle.bundle"]];
        
        [self folderSizeAtPath:filePath];

  • 相关阅读:
    poj 3253超时
    poj 3617输出格式问题
    dfs的返回条件
    hdu1010感想
    2018.7.19训练赛总结
    2018.7.12训练赛 -G
    汇编实验16 编写包含多个功能子程序的中断例程——浅谈直接地址表
    新的一年来了,先看一看自己的编程能力吧!
    汇编实验15:安装新的int 9中断例程
    汇编实验14:访问CMOS RAM
  • 原文地址:https://www.cnblogs.com/mfrbuaa/p/3759133.html
Copyright © 2020-2023  润新知