ios 删除系统从相册压缩的视频
iOS的沙盒机制,应用只能访问自己应用目录下的文件。iOS不像android,没有SD卡概念,不能直接访问图像、视频等内容。iOS应用产生的内容,如图像、文件、缓存内容等都必须存储在自己的沙盒内。默认情况下,每个沙盒含有3个文件夹:Documents, Library 和 tmp。Library包含Caches、Preferences目录。
上面的完整路径为:用户->资源库->Application Support->iPhone Simulator->6.1->Aplications
Documents:苹果建议将程序创建产生的文件以及应用浏览产生的文件数据保存在该目录下,iTunes备份和恢复的时候会包括此目录
Library:存储程序的默认设置或其它状态信息;
Library/Caches:存放缓存文件,保存应用的持久化数据,用于应用升级或者应用关闭后的数据保存,不会被itunes同步,所以为了减少同步的时间,可以考虑将一些比较大的文件而又不需要备份的文件放到这个目录下。
tmp:提供一个即时创建临时文件的地方,但不需要持久化,在应用关闭后,该目录下的数据将删除,也可能系统在程序不运行的时候清除。
APP Sandbox
iOS怎么获取沙盒路径,怎么操作文件呢?下面给出答案。
获取应用沙盒根路径:
- -(void)dirHome{
- NSString *dirHome=NSHomeDirectory();
- NSLog(@"app_home: %@",dirHome);
- }
获取Documents目录路径:
- //获取Documents目录
- -(NSString *)dirDoc{
- //[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
- NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
- NSString *documentsDirectory = [paths objectAtIndex:0];
- NSLog(@"app_home_doc: %@",documentsDirectory);
- return documentsDirectory;
- }
获取Library目录路径:
- //获取Library目录
- -(void)dirLib{
- //[NSHomeDirectory() stringByAppendingPathComponent:@"Library"];
- NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
- NSString *libraryDirectory = [paths objectAtIndex:0];
- NSLog(@"app_home_lib: %@",libraryDirectory);
- }
获取Cache目录路径:
- //获取Cache目录
- -(void)dirCache{
- NSArray *cacPath = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
- NSString *cachePath = [cacPath objectAtIndex:0];
- NSLog(@"app_home_lib_cache: %@",cachePath);
- }
获取Tmp目录路径:
- //获取Tmp目录
- -(void)dirTmp{
- //[NSHomeDirectory() stringByAppendingPathComponent:@"tmp"];
- NSString *tmpDirectory = NSTemporaryDirectory();
- NSLog(@"app_home_tmp: %@",tmpDirectory);
- }
创建文件夹:
- //创建文件夹
- -(void *)createDir{
- NSString *documentsPath =[self dirDoc];
- NSFileManager *fileManager = [NSFileManager defaultManager];
- NSString *testDirectory = [documentsPath stringByAppendingPathComponent:@"test"];
- // 创建目录
- BOOL res=[fileManager createDirectoryAtPath:testDirectory withIntermediateDirectories:YES attributes:nil error:nil];
- if (res) {
- NSLog(@"文件夹创建成功");
- }else
- NSLog(@"文件夹创建失败");
- }
创建文件
//创建文件
- -(void *)createFile{
- NSString *documentsPath =[self dirDoc];
- NSString *testDirectory = [documentsPath stringByAppendingPathComponent:@"test"];
- NSFileManager *fileManager = [NSFileManager defaultManager];
- NSString *testPath = [testDirectory stringByAppendingPathComponent:@"test.txt"];
- BOOL res=[fileManager createFileAtPath:testPath contents:nil attributes:nil];
- if (res) {
- NSLog(@"文件创建成功: %@" ,testPath);
- }else
- NSLog(@"文件创建失败");
- }
写数据到文件:
- //写文件
- -(void)writeFile{
- NSString *documentsPath =[self dirDoc];
- NSString *testDirectory = [documentsPath stringByAppendingPathComponent:@"test"];
- NSString *testPath = [testDirectory stringByAppendingPathComponent:@"test.txt"];
- NSString *content=@"测试写入内容!";
- BOOL res=[content writeToFile:testPath atomically:YES encoding:NSUTF8StringEncoding error:nil];
- if (res) {
- NSLog(@"文件写入成功");
- }else
- NSLog(@"文件写入失败");
- }
读文件数据:
- //读文件
- -(void)readFile{
- NSString *documentsPath =[self dirDoc];
- NSString *testDirectory = [documentsPath stringByAppendingPathComponent:@"test"];
- NSString *testPath = [testDirectory stringByAppendingPathComponent:@"test.txt"];
- // NSData *data = [NSData dataWithContentsOfFile:testPath];
- // NSLog(@"文件读取成功: %@",[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
- NSString *content=[NSString stringWithContentsOfFile:testPath encoding:NSUTF8StringEncoding error:nil];
- NSLog(@"文件读取成功: %@",content);
- }
文件属性:
- //文件属性
- -(void)fileAttriutes{
- NSString *documentsPath =[self dirDoc];
- NSString *testDirectory = [documentsPath stringByAppendingPathComponent:@"test"];
- NSFileManager *fileManager = [NSFileManager defaultManager];
- NSString *testPath = [testDirectory stringByAppendingPathComponent:@"test.txt"];
- NSDictionary *fileAttributes = [fileManager attributesOfItemAtPath:testPath error:nil];
- NSArray *keys;
- id key, value;
- keys = [fileAttributes allKeys];
- int count = [keys count];
- for (int i = 0; i < count; i++)
- {
- key = [keys objectAtIndex: i];
- value = [fileAttributes objectForKey: key];
- NSLog (@"Key: %@ for value: %@", key, value);
- }
- }
删除文件:
//删除文件
- -(void)deleteFile{
- NSString *documentsPath =[self dirDoc];
- NSString *testDirectory = [documentsPath stringByAppendingPathComponent:@"test"];
- NSFileManager *fileManager = [NSFileManager defaultManager];
- NSString *testPath = [testDirectory stringByAppendingPathComponent:@"test.txt"];
- BOOL res=[fileManager removeItemAtPath:testPath error:nil];
- if (res) {
- NSLog(@"文件删除成功");
- }else
- NSLog(@"文件删除失败");
- NSLog(@"文件是否存在: %@",[fileManager isExecutableFileAtPath:testPath]?@"YES":@"NO");
- }
ios 删除系统从相册压缩的视频的更多相关文章
- 微信 6.5.1 for iOS发布 可以在朋友圈分享相册中的视频
今天微信 6.5.1 for iOS发布了,最主要的一个功能是可以在朋友圈分享相册中的视频,卖转发朋友圈视频软件的家伙估计要哭了.微信这次更新,更有利于个人号的运营,个人号的价值将更高.先定一个小目标 ...
- ios怎样实现快速将显卡中数据读出压缩成视频在cocos2dx扩展开发中
如果解决ios怎样实现快速将显卡中数据读出压缩成视频在cocos2dx扩展开发中 手机平台性能是个关键问题. 压缩视频分成3个步骤: 读取显卡数据, 使用编码器压缩,保存文件. 使用libav 压缩的 ...
- ios获取摄像头与相册图片
iOS的一些设备上都安装了摄像头.现在绝大多数都有了. 在编程中,我们是用相应的东西来进行照相,录像等功能. 一.UIImagePickerController类 UIImagePickerCon ...
- 第九章、文件与文件系统的压缩与打包 Linux 系统常见的压缩命令
Linux 系统常见的压缩命令: 在Linux中,压缩文件的扩展名大多是:『*.tar, *.tar.gz, *.tgz, *.gz, *.Z, *.bz2』 Linux 支持的压缩命令非常多,且不同 ...
- 16 Linux系统的文件压缩、解压与归档
这一节的内容,我们详细介绍下Linux的文件压缩.解压缩与文件归档的内容,也就是tar.gzip.bzip2.xz等命令的内容: 压缩(compress)与解压缩(uncompress) Linux系 ...
- iOS 系统架构及常用框架(iOS的系统架构分为四个层次)
1.iOS基于UNIX系统,因此从系统的稳定性上来说它要比其他操作系统的产品好很多 2.iOS的系统架构分为四层,由上到下一次为:可触摸层(Cocoa Touch layer).媒体层(Media l ...
- 【iOS】系统框架学习
iOS的系统架构分为四个层次:核心操作系统层(Core OS layer).核心服务层(Core Services layer).媒体层(Media layer)和可触摸层(Cocoa Touch l ...
- 修正iOS从照相机和相册中获取的图片 方向
修正iOS从照相机和相册中获取的图片 方向 修正iOS从照相机和相册中获取的图片 方向 使用系统相机拍照得到的图片的默认方向有时不是ImageOrientationDown,而是ImageOrie ...
- Linux系统下文件压缩与打包命令
Linux系统下文件压缩与打包命令 常用的压缩文件拓展名 * .Z * .zip * .gz * .bz2 * .xz * .tar * .tar.gz * .tar.bz2 * .tar.xz 压缩 ...
随机推荐
- JavaScript 正则表达式提取感兴趣的字符串
var tdid="gov_sslim"; var reg=/(\w+)lim/; var name=tdid.match(reg); console.log(name[1]); ...
- 1117 新冲刺 day1
项目需求确定 现阶段我们进行的项目是到店点餐系统.主要是开发手机端app为用户提供方便快捷的点餐服务.免去顾客到店后遇到因吃饭的人太多而找不到服务人员点餐的窘境.减少了服务人员因为忙碌而导致下单慢的问 ...
- struts2 s:if标签以及 #,%{},%{#}的使用方法
<s:if>判断字符串的问题: 1.判断单个字符:<s:if test="#session.user.username=='c'"> 这样是从session ...
- jQuery实现星星评分功能
一.这是我做的调查问卷中的一个功能.(第三方MVC框架) 二.功能说明:1.用户点击星星,将值放到隐藏域中.2.用户可以重新点击星星修改回答. 前台JS代码: <script type=&quo ...
- ASP.NET中使用DropDownList实现无刷新二级联动详细过程
Demo.sql create table Car( [id] int identity, ) not null, ) not null ) go insert into Car ([brand],[ ...
- ExtJs4 笔记(4) Ext.XTemplate 模板
ExtJs4 笔记(4) Ext.XTemplate 模板 摘自:http://www.cnblogs.com/lipan/ 本篇将涉及到ExtJs中一个重要的概念,模板.话说Razor很神奇,但是我 ...
- jquery实现网页选项卡
这个功能在现在的网站中使用较为普遍,就是以选项卡的形式来对一些内容做了分类.,比如下面的天猫商城. 下面的源码是仿照天猫写的一个选项卡,实现起来的效果如下. 主要是利用我们在点击相应板块是触发它的单击 ...
- 客户端(Winform窗体)上传文件到服务器(web窗体)简单例子
客户端:先创建一个winform窗体的应用程序项目 项目结构
- Winform调用QQ发信息并且开机启动 (开源)
前言 公司CS系统需要加入启动qq从winform调用qq聊天窗口的功能,前提是需要将聊天者的QQ号码作为参数传递到函数中,一直没有搞过,正好很感兴趣,就折腾,Winform调用qq,我想肯定是需要一 ...
- Hadoop Pipes Exception: Illegal text protocol command
Hadoop Pipes Exception: Illegal text protocol command 对于Hadoop pipes 出现这样的错误,基本上编译代码依赖的.so和.a 版本不匹配 ...