NSString* path = [[NSBundle mainBundle] pathForResource:@"js" ofType:nil];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
if (path != nil) {
NSFileManager *fm = [NSFileManager defaultManager];
NSString* move_path = [NSString stringWithFormat:@"%@", [paths objectAtIndex:0]];
NSError *error;
if ([fm moveItemAtPath:path toPath:move_path error:&error]) {
NSLog(@"***************** success!");
} else {
NSLog(@"***************** fail!");
} }
It fails without fail.
js & move_js is not n开发者_StackOverflow中文版ull;
path = /var/mobile/Applications/06C82222-0ABF-4009-BD58-31B799DC7C33/adhoc.app/js
move_path = /var/mobile/Applications/06C82222-0ABF-4009-BD58-31B799DC7C33/Documents
You're trying to move file from application bundle but you can't do so - you can't change anything in it. Instead of moving the file just copy it:
if ([fm copyItemAtPath:path toPath:move_path error:&error]) {
精彩评论