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];
}
}
Như thế này.Sao chép thư mục từ thư mục Tài nguyên iPhone vào thư mục tài liệu
Resources/DB/words.csv => DB thư mục bản sao => Tài liệu/DB/words.csv
Tôi muốn sao chép thư mục con DB tại thư mục Resources. Tôi nghĩ rằng nguồn là tốt. Nhưng nguồn đó tạo thư mục và không sao chép các tệp trong thư mục DB tại thư mục Tài nguyên.
Tôi thực sự muốn sao chép tệp trong thư mục DB tại thư mục Tài nguyên. làm ơn giúp tôi.
OH !! thực sự thực sự cảm ơn !! cảm ơn!! – Beomseok