新建多级目录

#define ADWO_BASE_FILES_DIRECTORY       @"~/Library/Caches/first/"


#define APP_STARTING_DIRECTORY         "second/"


NSFileManager*fileMgr = [NSFileManagerdefaultManager];

   

NSString*path = [ADWO_BASE_FILES_DIRECTORYAPP_STARTING_DIRECTORYstringByExpandingTildeInPath];


if(![fileMgrfileExistsAtPath:path])

   {

       [fileMgrcreateDirectoryAtPath:path  withIntermediateDirectories:YESattributes:nilerror:nil];

   }

//这里必须设置为YES.否则无法建立多级目录


  NSData*data = [NSDatadataWithContentsOfFile:[[NSBundlemainBundle]pathForResource:@"books"ofType:@"jpg"]];


  NSString*str = [NSStringstringWithFormat:@"%@/starting.png", path] ;


[data  writeToFile:stratomically:YES];

你可能感兴趣的:(Path)