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这个头文件. 今天我们主要介绍的 ...
随机推荐
- 转!!Java 基础面试题的剖析: short s1=1;s1 = s1 +1 报错? s1+=1 呢
short s1=1;s1 = s1 +1会报错吗? package common; public class ShortTypeTest { /* * @param args */ publi ...
- matlab灰度变彩色+白平衡算法实现
% matlab彩色图像分离通道并合并成处理后的彩色图像(彩色变灰度再变彩色) % 白平衡算法(灰度世界法)消除RGB受光照影响 clear all; close all; %读入原始图像 srcIm ...
- 如何使用 declare-styleable
如何使用 declare-styleable 在创建 xml 到 objectName/res/values/ 命名为 attrs.xml 编辑文件内容为(示例)<?xml version=&q ...
- APMServ本地搭建网站最好用的软件
APMServ 5.2.6 是一款拥有图形界面的快速搭建Apache 2.2.9.PHP 5.2.6.MySQL 5.1.28&4.0.26.Nginx 0.7.19.Memcached 1. ...
- iOS 沙盒(sandbox)机制和文件操作
本文参看了 http://www.uml.org.cn/mobiledev/201209211.asp#1 这篇文章中的介绍,尊重原著. 1.IOS沙盒机制 IOS应用程序只能在本应用程序中创建的文件 ...
- Java软件工程师全栈技能
1.前端基础技能,掌握html.js.css,会用jquery.bootstrap. 2.前端技能升级,会用echart.BMap等等. 3.前端高级技能,熟练使用angularjs等等. 4.服务端 ...
- div滚动条演示
<!DOCTYPE html> <html> <head> <meta charset="gb2312" /> <title& ...
- 例题:计算运费。c#语言基础,比较简单。看代码输入格式和方法。同样方法可以做一个 出租车打车的程序
while (true) { Console.WriteLine("请输入行李重量"); double k = Convert.ToDouble(Console .ReadLine ...
- 清理无用的CSS样式的几个工具(转)
欢迎和大家交流技术相关问题: 邮箱: jiangxinnju@163.com 博客园地址: http://www.cnblogs.com/jiangxinnju GitHub地址: https://g ...
- 利用mycat实现mysql数据库读写分离
1.这里是在mysql主从复制实现的基础上,利用mycat做读写分离,架构图如下: 2.Demo 2.1 在mysql master上创建数据库创建db1 2.2 在数据库db1创建表student ...