iOS 使用 NSFileManager对沙盒里面的文件和目录,增加,修改,删除操作;

- (void)viewDidLoad
{
[super viewDidLoad]; self.title = @"NSFileManager"; NSFileManager *defauleManager = [NSFileManager defaultManager];
NSString *tempPath = NSTemporaryDirectory();
NSLog(@"%@",tempPath);
NSString *thePath = nil; //创建一个目录: 在temp下创建 MyFoler目录
// thePath = [NSString stringWithFormat:@"%@/MyFolder",tempPath];
// [defauleManager createDirectoryAtPath:thePath withIntermediateDirectories:YES attributes:nil error:nil]; //写入一个文件 在 temp目录下
// NSString *aStr = @"hello world";
// thePath = [NSString stringWithFormat:@"%@hello.txt",tempPath];
// [aStr writeToFile:thePath atomically:YES encoding:NSUTF8StringEncoding error:nil]; //显示目录内容
//NSLog(@"temp目录内容:%@",[defauleManager contentsOfDirectoryAtPath:tempPath error:nil]); //删除一个文件
// NSString *deleteStr = @"delete Str";
// thePath = [NSString stringWithFormat:@"%@delete.txt",tempPath];
// [deleteStr writeToFile:thePath atomically:YES encoding:NSUTF8StringEncoding error:nil];
// NSLog(@"temp目录内容:删除之前:%@",[defauleManager contentsOfDirectoryAtPath:tempPath error:nil]);
// [defauleManager removeItemAtPath:thePath error:nil];
// NSLog(@"temp目录内容:删除之后:%@",[defauleManager contentsOfDirectoryAtPath:tempPath error:nil]); //删除一个目录:
// thePath = [NSString stringWithFormat:@"%@/TestFoler",tempPath];
// [defauleManager createDirectoryAtPath:thePath withIntermediateDirectories:YES attributes:nil error:nil];
// NSLog(@"temp目录内容:%@",[defauleManager contentsOfDirectoryAtPath:tempPath error:nil]);
// [defauleManager removeItemAtPath:thePath error:nil];
// NSLog(@"temp目录内容:%@",[defauleManager contentsOfDirectoryAtPath:tempPath error:nil]); //获取目录下的所有文件列表:
NSArray *fileList = [defauleManager contentsOfDirectoryAtPath:tempPath error:nil];
NSLog(@"%@",fileList); //判断一个目录是否是文件夹
//- (BOOL)fileExistsAtPath:(NSString *)path isDirectory:(BOOL *)isDirectory }

最新文章

  1. App前后台判断
  2. 配置文件的生成,关于“make menuconfig”
  3. java三种实现线程的方法比较
  4. android中实现跑马灯效果以及AutoCompleteTestView与MultiAutoCompleteTextView的学习
  5. 如何关闭Linux里边的selinux ?
  6. Optimizing shaper — hashing filters (HTB)
  7. 原生javascript满屏上下滚动
  8. VMware虚拟机安装Linux系统后IP配置(二)
  9. win7 安装用mingw编译的Qt源码并连接postgresql
  10. Azure monitor Portal 、Azure monitor API监控指标、性能监视器常用指标
  11. redis入门知识汇总
  12. js 动态调用字符串方法并传入对应参数
  13. Autowired byType 与 byName 策略
  14. 手动建立mapping以及增加属性
  15. 计算概论(A)/基础编程练习1(8题)/2:苹果和虫子
  16. elk之elasticsearch安装
  17. android studio 查看大纲
  18. hadoop JOB的性能优化实践
  19. ArcGIS URL 组成
  20. Learning Perl 第九章习题第二题

热门文章

  1. 【PHPExcel实例】 php 导出 excel 实例
  2. CF1025B Weakened Common Divisor【数论/GCD/思维】
  3. 在sublime Text 3上编写并运行java程序
  4. Codeforces Round #307 (Div. 2) E. GukiZ and GukiZiana(分块)
  5. Visual Studio找不到adb.exe错误解决
  6. 【BZOJ 4650】【UOJ #219】【NOI 2016】优秀的拆分
  7. [AGC027F]Grafting
  8. 【二分查找】POJ2456-Aggressive cows
  9. [JZOJ5426]摘Galo
  10. datatable无法设置横向滚动条(设置无效)