BOOL success;
NSFileManager *fileManager = [[NSFileManager defaultManager]autorelease];
NSError *error;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *documentDBFolderPath = [documentsDirectory stringByAppendingPathComponent:@"DB"];
success = [fileManager fileExistsAtPath:documentDBFolderPath];
if (success){
return;
}else{
NSString *resourceDBFolderPath = [[[NSBundle mainBundle] resourcePath]
stringByAppendingPathComponent:@"DB"];
[fileManager createDirectoryAtPath: documentDBFolderPath attributes:nil];
[fileManager copyItemAtPath:resourceDBFolderPath toPath:documentDBFolderPath
error:&error];
}
}
像这样。将文件夹从iPhone Resources目录复制到文档目录
资源/ DB/words.csv => DB文件夹拷贝=>文件/数据库/ words.csv
我想DB子目录资源文件夹复制。我认为这个来源是很好的。但是该源生成文件夹,并且不会将资源文件夹中DB文件夹中的文件复制。
我真的想复制资源文件夹中DB文件夹中的文件。请帮帮我。
哦!真的非常感谢!谢谢!! – Beomseok 2010-01-31 10:15:34