zoukankan      html  css  js  c++  java
  • NSFileManager 沙盒文件管理

    文件夹创建,复制,移动,删除,检查是否存在,代码如下:

    1.获取沙盒 document 路径,作为文件夹路径的基路径.

      NSString *document = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];

    2.创建 NSFileMAnager:

      NSFileManager *manager = [NSFileManager defaultManager];

    3.创建文件夹

      a.拼接文件夹路径: NSString *newFile = [document stringByAppendingPathComponent :@"QQQQ"];

      b.创建文件夹: [manager createDirectoryAtPath:newFile withIntermediateDirectories:YES attributes:nil error:nil];  

    4.移动文件夹:

      a.拼接要移动到的地址: NSString *movePath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"QQQQ"];

      b.移动文件夹:[manager moveItemAtPath:newFile toPath:movePath error:nil];

    5.判断文件夹是否存在

      [manager fileExistsAtPath:movePath]; 返回值 BOOL

    6.删除文件夹

      [manager removeItemAtPath:movePath error:nil];

    7.复制文件夹

      [manager copyItemAtPath:movePath toPath:newFile error:nil];

  • 相关阅读:
    SPI简述
    stm32和sd卡
    BKP和RTC
    Lwip与底层的接口
    关于Ad-hoc
    stm32 引脚映射 和 ADC
    GDB使用总结
    linux管道和重定向
    学习python的第四天
    学习pyton的第三天
  • 原文地址:https://www.cnblogs.com/Ager/p/4940525.html
Copyright © 2011-2022 走看看