copy files from mainbundle to document directory
Hi all and thanks in advance. Im trying to copy several images called graph, graph1.. from document directory to mainbundle (icons folder) by using this:
NSArray *paths1 = NSSearchPathForDirectoriesInDomains(NSDocumentDire ctory, NSUserDomainMask, YES);
NSString * ja1 = [paths1 objectAtIndex:0];
NSString *filename3 = [NSString stringWithFormat:@"%@/graph.png", ja1];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error;
NSString *jur = [NSString stringWithFormat:@"%@/%@", [[NSBundle mainBundle] bundlePath],@"icons/"];
NSString *defaultPath = [jur stringByAppendingString:@"graph.png"];
if ([fileManager fileExistsAtPath:defaultPath]==NO)
NSLog(@"file doesnt exits");
if ([fileManager fileExistsAtPath:defaultPath]){
NSLog(@"file already exits");
if ([fileManager removeItemAtPath:defaultPath error:&error]==YES)
NSLog(@"delete it");
}
if ([fileManager fileExistsAtPath:filename3])
NSLog(@"file2 already exits");
if ([fileManager copyItemAtPath:filename3 toPath:defaultPath error:&error])
NSLog(@"done");
Once i build the project i receive an error: Failed to create writable file with message 'The operation couldn’t be completed. No such file or directory'
Im sure its a dumb question but i really cant get it done so if anyone can help me i would appreciate
Thanks,
Angel.
|