ios copy项目文件到Documents目录下

 

 
NSFileManager*fileManager =[NSFileManager defaultManager];
NSError*error;
NSArray*paths =NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
NSString*documentsDirectory =[paths objectAtIndex:0];

NSString*txtPath =[documentsDirectory stringByAppendingPathComponent:@"txtFile.txt"];

if([fileManager fileExistsAtPath:txtPath]== NO){
   
NSString*resourcePath =[[NSBundle mainBundle] pathForResource:@"txtFile" ofType:@"txt"];
   
[fileManager copyItemAtPath:resourcePath toPath:txtPath error:&error];
}

posted on 2012-10-12 13:43  爱直至成伤lie  阅读(8729)  评论(0编辑  收藏  举报