29,031
社区成员
发帖
与我相关
我的任务
分享
NSString *realPath=[NSHomeDirectory() stringByAppendingPathComponent:@"Documents/xx.sqlite"];
NSError *error;
NSURL *url = [NSURL URLWithString:realPath];
if ([fileManager fileExistsAtPath:realPath]) {
NSLog(@"文件存在");
[fileManager removeItemAtURL:url error:&error];//删除不了哦
NSLog(@"error=%@",error);
}
if (![fileManager copyItemAtPath:sourcePath toPath:realPath error:&error])
{//只要文件存在就不能复制,也不能覆盖。
NSLog(@"%@",[error localizedDescription]);
}
else {
NSLog(@"成功复制%@到路径:%@。",sourcePath,realPath);
}