iphone获取当前磁盘信息
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
-( float )getFreeDiskspace { float totalSpace; float totalFreeSpace; float totalUsedSpace; 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]; NSNumber *freeFileSystemSizeInBytes = [dictionary objectForKey:NSFileSystemFreeSize]; totalSpace = [fileSystemSizeInBytes floatValue]; totalFreeSpace = [freeFileSystemSizeInBytes floatValue]; totalUsedSpace = totalSpace - totalFreeSpace; float freePercent = totalFreeSpace/totalSpace; float usedPercent = totalUsedSpace/totalSpace; freePercentLabel.text = [[NSString stringWithFormat:@ "%.2f" ,freePercent*100] stringByAppendingString:@ "%" ]; usedPercentLabel.text = [[NSString stringWithFormat:@ "%.2f" ,usedPercent*100] stringByAppendingString:@ "%" ]; totalSpaceLabel.text = [[NSString stringWithFormat:@ "%.2f" ,((totalSpace/1024.0f)/1024.0f/1024.0f)] stringByAppendingString:@ "GB" ]; usedSpaceLabel.text = [[NSString stringWithFormat:@ "%.2f" ,((totalUsedSpace/1024.0f)/1024.0f/1024.0f)] stringByAppendingString:@ "GB" ]; freeSpaceLabel.text = [[NSString stringWithFormat:@ "%.2f" ,((totalFreeSpace/1024.0f)/1024.0f/1024.0f)] stringByAppendingString:@ "GB" ]; NSLog(@ "Memory Capacity of %f GB with %f GB Free memory available." , ((totalSpace/1024.0f)/1024.0f/1024.0f), ((totalFreeSpace/1024.0f)/1024.0f)/1024.0f); } else { NSLog(@ "Error Obtaining System Memory Info: Domain = %@, Code = %@" , [error domain], [error code]); } return totalFreeSpace; } |
iphone获取当前磁盘信息的更多相关文章
- iphone获取sim卡信息
/* iphone获取sim卡信息 1.加入一个Framework(CoreTelephony.framework). 2.引入头文件 #import <CoreTelephony/CTTele ...
- iphone获取当前流量信息
通过读取系统网络接口信息,获取当前iphone设备的流量相关信息,统计的是上次开机至今的流量信息. 代码 悦德财富:https://yuedecaifu.com 1 2 3 4 5 6 7 8 9 1 ...
- C#获取本地磁盘信息【转载】
直接上干货简单易懂 //磁盘监控(远程/本地)//需要引用System.Management.dllpublic class RemoteMonitoring{private static str ...
- C#获取本地磁盘信息
直接上干货简单易懂 //磁盘监控(远程/本地) //需要引用System.Management.dll public class RemoteMonitoring { private static s ...
- linux下 stat statfs 获取 文件 磁盘 信息
stat函数讲解 表头文件: #include <sys/stat.h> #include <unistd.h> 定义函数: int st ...
- Powershell获取磁盘信息
使用Powershell完成系统管理实在是太方便了,磁盘信息获取只需几行代码即可. 1: $DiskCount = ((Get-WmiObject -Class Win32_DiskDrive).Ca ...
- C#获取本机磁盘信息
照着书敲的.留作笔记吧. using System; using System.Collections.Generic; using System.Linq; using System.Text; u ...
- C++ 通过WIN32 API 获取逻辑磁盘详细信息
众所周知,在微软的操作系统下编写应用程序,最主要的还是通过windows所提供的api函数来实现各种操作的,这些函数通常是可以直接使用的,只要包含windows.h这个头文件, 下载源文件 今天我们主 ...
- C++通过WIN32 API获取逻辑磁盘详细信息
众所周知,在微软的操作系统下编写应用程序,最主要的还是通过windows所提供的api函数来实现各种操作的,这些函数通常是可以直接使用的,只要包含windows.h这个头文件. 今天我们主要介绍的 ...
随机推荐
- return 还是 不return
jQuery.fn.functiona = function() { //return this.each(function() { **** } jQuery(this).css('backgrou ...
- 线性表 - 从零开始实现by C++
参考链接:数据结构探险之线性表篇 线性表
- virtualBox虚拟机安装与主机互访和实现上网配置
1.到官方网下载vitualBox虚拟机,目前最新版本5.0,并安装. https://www.virtualbox.org/ 2.下载安装CentOS系统安装文件 本文采用CentOS-6.5-i3 ...
- vc++编译libtiff4.0.4
目录 第1章简介 1 第2章命令行编译 2 2.1 编译 2 2.1.1 使用VC++2010编译 2 2.1.2 使用VC++6编译 4 2.2 生成的文件 5 ...
- js中event.target和event.srcElement的区别
看了很多资料绝对结果就是 firefox 下的 event.target = IE 下的 event.srcElement jquery中的event.target属性的作用是获取到出发事件的元素.j ...
- [BI基础] ( 商务智能 ) 简介
一.什么是BI BI(商务智能)通过给海量云数据制定“游戏规则”(对不同主题进行不同分析),将分散的数据进行搜集.整合.清理和诊断,借助一定的分析手段,进而将数据转化为信息和知识,快速准确的提供报表并 ...
- HTML5自学笔记[ 2 ]新增表单控件和表单属性
新增<input>属性type="email",自动验证,若输入不为邮箱,则不能提交. 新增<input>属性type="tel",在移 ...
- hdu 4315 Climbing the Hill(阶梯博弈转nim博弈)
Climbing the Hill Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
- NOR FLASH与NAND FLASH的区别
NOR和NAND是现在市场上两种主要的非易失闪存技术.Intel于1988年首先开发出NOR flash技术,彻底改变了原先由EPROM和EEPROM一统天下的局面.紧接着,1989年,东芝公司发表了 ...
- 超实用的JavaScript代码段 --倒计时效果
现今团购网.电商网.门户网等,常使用时间记录重要的时刻,如时间显示.倒计时差.限时抢购等,本文分析不同倒计时效果的计算思路及方法,掌握日期对象Date,获取时间的方法,计算时差的方法,实现不同的倒时计 ...