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