博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
文件大小计算
阅读量:4675 次
发布时间:2019-06-09

本文共 940 字,大约阅读时间需要 3 分钟。

#import "ViewController.h"@interface ViewController ()@property (nonatomic,assign) CGFloat size;@end@implementation ViewController- (void)viewDidLoad {    [super viewDidLoad];    NSString * path = @"/Users/tc/Desktop/图片text";    NSLog(@"%g",[self FileSize:path]);}/** *  @param path 文件的绝对路径 */- (CGFloat)FileSize:(NSString *)path{        NSFileManager * manager = [NSFileManager defaultManager];        NSArray * arr = [manager contentsOfDirectoryAtPath:path error:nil];        BOOL isDir;    for (NSString * fileName in arr) {        NSString * filePath = [path stringByAppendingPathComponent:fileName];        if (!([manager fileExistsAtPath:filePath isDirectory:&isDir] && isDir)) {            NSDictionary * dic = [manager attributesOfItemAtPath:filePath error:nil];            _size += dic.fileSize;        }else{            [self FileSize:filePath];        }    }    return _size;}@end

 

转载于:https://www.cnblogs.com/tcbky/p/5657392.html

你可能感兴趣的文章
Eclipse序列号生成代码
查看>>
JVM
查看>>
设计模式记录
查看>>
SPF,DSPF,RDPF,SPEF and SBPF.
查看>>
JS学习文章
查看>>
window系统服务器,远程连接mysql数据库。
查看>>
CAS总结之Ticket篇
查看>>
Python2.7升级至Python3.6
查看>>
框架集
查看>>
003
查看>>
HDU 2923 Einbahnstrasse (最短路,3级)
查看>>
实验吧-密码学-我喜欢培根
查看>>
java set集合与List集合练习
查看>>
简短总结一下C#里跨线程更新UI
查看>>
201612-2 工资计算
查看>>
DevExpress下拉多选框 CheckComboboxEdit、CheckedListBoxControl
查看>>
HashMap实现缓存
查看>>
javax.persistence.TransactionRequiredException: Executing an update/delete query
查看>>
Gym 100733G No Negations
查看>>
C++ 编写的DLL导出的函数名乱码含义解析
查看>>