zoukankan      html  css  js  c++  java
  • iOS中判断一个文件夹是否存在

    - (void)createFileDirectories

    {

        // 判断存放音频、视频的文件夹是否存在,不存在则创建对应文件夹

        NSFileManager *fileManager = [NSFileManagerdefaultManager];

        BOOL isDir = FALSE;

        BOOL isDirExist = [fileManager fileExistsAtPath:DOCUMENTS_FOLDER_AUDIOisDirectory:&isDir];

        

        if(!(isDirExist && isDir))

        {

            BOOL bCreateDir = [fileManager createDirectoryAtPath:DOCUMENTS_FOLDER_AUDIOwithIntermediateDirectories:YESattributes:nilerror:nil];

            if(!bCreateDir){

                NSLog(@"Create Audio Directory Failed.");

            }

            NSLog(@"%@",DOCUMENTS_FOLDER_AUDIO);

        }

        

        isDir = FALSE;

        isDirExist = [fileManager fileExistsAtPath:DOCUMENTS_FOLDER_VEDIOisDirectory:&isDir];

        

        if(!(isDirExist && isDir)){

            BOOL bCreateDir = [fileManager createDirectoryAtPath:DOCUMENTS_FOLDER_VEDIOwithIntermediateDirectories:YESattributes:nilerror:nil];

            if(!bCreateDir){

                NSLog(@"Create Audio Directory Failed.");

            }

            NSLog(@"%@",DOCUMENTS_FOLDER_VEDIO);

        }

    }

  • 相关阅读:
    NSOperation
    iOS 数据持久化方案
    JS高级学习历程-15
    JavaScript进阶
    JavaScript进阶
    JavaScript进阶
    JS高级学习历程-14
    JavaScript进阶
    Linux 添加硬盘并分区
    VxWorks实验八 信号
  • 原文地址:https://www.cnblogs.com/zhwl/p/2881272.html
Copyright © 2011-2022 走看看