jak skopiować plik z głównego pakietu do folderu dokumentów
Chcę sprawdzić jeden plik w folderze Dokument. Chcę, aby ten plik nie istniał w folderze dokumentu, skopiuj go z głównego pakietu do folderu dokumentu. Piszę ten kod i ten plik do skopiowania, ale mój problem tutaj ..... !!!! mój plik to plik .sqlite (plik bazy danych) i kiedy kopia do folderu dokumentu nie ma danych w sobie !!!! czemu??? podczas gdy ten plik w głównym pakiecie zawiera dane w sobie.
to jest mój kod, ale nie wiem, dlaczego nie działa !!!!
#define DataName @"mydatabase.sqlite"
- (void)viewDidLoad
{
[self CopyDatabase];
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
- (NSString*)DatabasePath
{
NSArray *Paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *DocumentDir = [Paths objectAtIndex:0];
//NSLog(@"%@",DocumentDir);
return [DocumentDir stringByAppendingPathComponent:DataName];
}
- (void)CopyDatabase
{
BOOL success;
NSFileManager *fileManager = [NSFileManager defaultManager];
success = [fileManager fileExistsAtPath:[self DatabasePath]];
NSString *FileDB = [[[NSBundle mainBundle]resourcePath]stringByAppendingPathComponent:DataName];
if (success)
{
NSLog(@"File Exist");
return;
}
else
{
[fileManager copyItemAtPath:FileDB toPath:[self DatabasePath] error:nil];
}
}