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!");
} }
它失败了。
js& move_js不为null;
path = /var/mobile/Applications/06C82222-0ABF-4009-BD58-31B799DC7C33/adhoc.app/js
move_path = /var/mobile/Applications/06C82222-0ABF-4009-BD58-31B799DC7C33/Documents
答案 0 :(得分:6)
您正在尝试从应用程序包中移动文件,但您无法执行此操作 - 您无法更改其中的任何内容。而不是移动文件只需复制它:
if ([fm copyItemAtPath:path toPath:move_path error:&error]) {