Hi
I am trying to copy an mp3 file from my Resources folder to a folder inside "Documents" folder of the app. On the simulator this works fine. But when I run it on a device, copying the files gives me this error
Operation could not be completed. (Cocoa error 513.)
The source and destinations paths are fine but I still cannot copy the file. Any ideas? Where can I find out what the cocoa error code 513 means?
Thanks.
Here's the relevant source code
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *folderPath = [documentsDirectory stringByAppendingPathComponent:@"Files"];
NSString *insPath = [NSString stringWithFormat:@"%@.mp3", fileName];
NSString *srcPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:insPath];
NSString *destPath = [folderPath stringByAppendingPathComponent:insPath];
NSLog(@"Src: %@, Dest: %@", srcPath, destPath);
NSError *err;
[fileManager moveItemAtPath:srcPath toPath:destPath error:&err];
NSLog(@"Err desc-%@", [err localizedDescription]);
NSLog(@"Err reason-%@", [err localizedFailureReason]);
Before making a call to moveItemAtPath, I am also creating the directory "Files" and it returns a YES.
Here's the log results
Src: /var/mobile/Applications/512D7565-7EF7-4C13-A015-19EEC3F3B465/MyApp.app/MyFile.mp3, Dest: /var/mobile/Applications/512D7565-7EF7-4C13-A015-19EEC3F3B465/Documents/Files/MyFile.mp3
Err desc-Operation could not be completed. (Cocoa error 513.)
Err reason-(null)
A question
Is there a limit to the file size when copying data from resources to Documents folder? The file I am trying to copy is about 5MB. Could that be a reason?