-(void)copyFileFromPath:(NSString*)sourcePath toPath:(NSString*)toPath{
NSFileManager *fileManager = [[NSFileManager alloc] init];
NSArray* array = [fileManagercontentsOfDirectoryAtPath:sourcePatherror:nil];
for(inti =0; i<[arraycount]; i++)
{
NSString *fullPath = [sourcePath stringByAppendingPathComponent:[array objectAtIndex:i]];
NSString *fullToPath = [toPath stringByAppendingPathComponent:[array objectAtIndex:i]];
NSLog(@"%@",fullPath);
NSLog(@"%@",fullToPath);
//判断是不是文件夹
BOOLisFolder =NO;
//判断是不是存在路径 并且是不是文件夹
BOOLisExist = [fileManagerfileExistsAtPath:fullPathisDirectory:&isFolder];
if(isExist){
NSError*err =nil;
[[NSFileManager defaultManager] copyItemAtPath:fullPath toPath:fullToPath error:&err];
NSLog(@"%@",err);
if(isFolder){
[selfcopyFileFromPath:fullPathtoPath:fullToPath];
}
}
}
}
网友评论