您的位置:首页 > 其它

获取磁盘空间大小

2010-02-08 11:57 417 查看
RT:

-(float)getTotalDiskSpaceInBytes {

float totalSpace = 0.0f;

NSError *error = nil;

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

NSDictionary *dictionary = [[NSFileManager defaultManager] attributesOfFileSystemForPath:[paths lastObject] error: &error];

if (dictionary) {

NSNumber *fileSystemSizeInBytes = [dictionary objectForKey: NSFileSystemSize];

totalSpace = [fileSystemSizeInBytes floatValue];

} else {

NSLog(@"Error Obtaining File System Info: Domain = %@, Code = %@", [error domain], [error code]);

}

return totalSpace;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: