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这个头文件. 今天我们主要介绍的 ...
随机推荐
- linux runlevel
Linux系统有7个运行级别(runlevel)运行级别0:系统停机状态,系统默认运行级别不能设为0,否则不能正常启动运行级别1:单用户工作状态,root权限,用于系统维护,禁止远程登陆运行级别2:多 ...
- K-均值聚类及其在生物信息中的应用
如果一点基础没有最好先拿起一本教材开始学,<机器学习实战>还不错,P93,书上有python源码和练习数据,非常适合新手. k均值聚类 名词:簇:相似度算法 伪代码 创建K个点作为起始质心 ...
- MySQL初级培训
按照一个MySQL DBA在工作中接触到部分的先后顺序,编排培训目录如下. 字段选取 int , decimal, char , varchar , blob ,timestamp SQL优化 exp ...
- 【转】 FPGA设计的四种常用思想与技巧
本文讨论的四种常用FPGA/CPLD设计思想与技巧:乒乓操作.串并转换.流水线操作.数据接口同步化,都是FPGA/CPLD逻辑设计的内在规律的体现,合理地采用这些设计思想能在FPGA/CPLD设计工作 ...
- 一个最简html5文档来说明html5的新特性和写法
<!DOCTYPE html> <html lang="zh"> <head> <meta charset="utf-8&quo ...
- Win7下Maven的安装与配置
简介 官网:https://maven.apache.org/ Apache Maven,是一个(特别是Java软件)项目管理及自动构建工具,由Apache软件基金会所提供.基于项目对象模型(Pro ...
- CSS3:不可思议的border属性&Web字体图标Font Awesome
CSS3:不可思议的border属性 转载至——译文:不可思议的CSS border属性 原文:Magic of CSS border property Web字体图标Font Awesome 转载 ...
- 连续型变量的推断性分析——t检验
连续型变量的推断性分析方法主要有t检验和方差分析两种,这两种方法可以解决一些实际的分析问题,下面我们分别来介绍一下这两种方法 一.t检验(Student's t test) t检验也称student ...
- python 使用*args 和**kwargs
def fun_var_args(farg, *args): print "arg:", farg for value in args: print "another a ...
- IO流 总结一
字符流: FileReader FileWriter BufferedReader BufferedWriter readLine(); 字节流: FileInputReader FileOutput ...