你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS開發綜合 >> ios 得到文件夾大小 進率是1000

ios 得到文件夾大小 進率是1000

編輯:IOS開發綜合
- (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];

  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved