IOS How to copy file from folder to folder
+(BOOL)copyFileAtPath:(NSString *)atPath toPath:(NSString *)toPath {
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error;
if (![[NSFileManager defaultManager] copyItemAtURL:[NSURL fileURLWithPath:atPath] toURL:[NSURL fileURLWithPath:toPath] error:&error]) {
NSLog(@"Error:%@",[error description]);
} else {
NSLog(@"atPath:%@ toPath:%@",atPath,toPath);
}
return [fileManager copyItemAtPath:atPath toPath:toPath error:nil];
}
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error;
if (![[NSFileManager defaultManager] copyItemAtURL:[NSURL fileURLWithPath:atPath] toURL:[NSURL fileURLWithPath:toPath] error:&error]) {
NSLog(@"Error:%@",[error description]);
} else {
NSLog(@"atPath:%@ toPath:%@",atPath,toPath);
}
return [fileManager copyItemAtPath:atPath toPath:toPath error:nil];
}
Comments
Post a Comment