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这个头文件. 今天我们主要介绍的 ...
随机推荐
- C#实现文件下载
1,Http 协议中有专门的指令来告知浏览器, 本次响应的是一个需要下载的文件. 格式如下:Content-Disposition: attachment;filename=filename.ext以 ...
- 项目解析- JspLibrary - part2
banner.jsp 验证用户是否登录 <%String manager=(String)session.getAttribute("manager"); //验证用户是否登 ...
- jsp 颜色和表格控制
表格控制: table{table-layout:fixed; word-wrap:break-word; word-break:break-all;} 颜色列表:
- Unity3D WebCamTexture 调用外部摄像头
http://www.itnose.net/detail/6259004.html 一:Unity 中使用WebCamTexture 调用摄像头实现拍照和摄像. using UnityEngine; ...
- vbox下android分辨率设置
VBoxManage setextradata "android" "CustomVideoMode1" "1280x800x16" 1. ...
- quartz定时任务框架的使用
quartz定时任务时间设置 这些星号由左到右按顺序代表 : * * * * * * * ...
- NOIP 2014 普及组 T3 螺旋矩阵
[题意] 已知:n,r,c(n<=30000) 条件:给定n行n列的螺旋矩阵(从矩阵的左上角(1,1)出发,初始时向右移动:如果前方是未曾经过的格子, 则继续前进,否则右转:重复上述操作直至经过 ...
- python 练习 22
Python程序语言指定任何非0和非空(null)值为true,0 或者 null为false. Python 编程中 if 语句用于控制程序的执行,基本形式为: if 判断条件: 执行语句…… el ...
- [saiku] 配置saiku实时展现查询数据
缘起: 在默认的情况下,saiku是不能对数据进行实时展现的,只能通过刷新按钮或者重启服务器来刷新数据 这样以来会有很多的麻烦,每天得手动去刷新,这个操作只有管理员可以操作,在刷新以前客户看到的都是缓 ...
- Spring事务的传播特性和隔离级别
事务的几种传播特性1. PROPAGATION_REQUIRED: 如果存在一个事务,则支持当前事务.如果没有事务则开启2. PROPAGATION_SUPPORTS: 如果存在一个事务,支持当前事务 ...