Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 11-11-2011, 05:55 AM   #1 (permalink)
Registered Member
 
Join Date: Nov 2011
Posts: 3
angeljurjurjur is on a distinguished road
Default 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.
angeljurjurjur is offline   Reply With Quote
Old 11-11-2011, 08:27 AM   #2 (permalink)
Registered Member
 
apatsufas's Avatar
 
Join Date: Jan 2011
Location: Thessaloniki, Greece
Posts: 121
apatsufas is on a distinguished road
Default

You can't copy a file to the apps main bundle neither can you remove a file from there, you can only read a file or copy it to the documents directory.
__________________
SQLed - Your Database Manager on the go

iAZConverter - Converts everything from A to Z
apatsufas is offline   Reply With Quote
Old 11-15-2011, 03:29 AM   #3 (permalink)
Registered Member
 
Join Date: Nov 2011
Posts: 3
angeljurjurjur is on a distinguished road
Default

Quote:
Originally Posted by apatsufas View Post
You can't copy a file to the apps main bundle neither can you remove a file from there, you can only read a file or copy it to the documents directory.
damn.. ok .. thanks so much!! i had no idea
angeljurjurjur is offline   Reply With Quote
Reply

Bookmarks

Tags
copy, documentdirectory, images, mainbundle

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 403
17 members and 386 guests
7twenty7, Alex-alex, Apptronics RBC, baja_yu, chiataytuday, dre, gwelmarten, ipodphone, jeroenkeij, jleannex55, matador1978, mbadegree, n00b, pbart, Retouchable, Sami Gh, usernametaken
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,676
Threads: 94,125
Posts: 402,910
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jleannex55
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 06:23 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0