iphone: copie ou mova o arquivo da pasta do diretório de documentos
Aqui está o meu código.
NSArray *pathSong = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *toPath = [[pathSong objectAtIndex:0] stringByAppendingPathComponent:@"Songs"];
NSString *fromPath=[[pathSong objectAtIndex:0] stringByAppendingPathComponent:@"abc"];
NSString *strdestination = [fromPath stringByAppendingPathComponent:@"sg.mp3"];
NSError *Error;
if([[NSFileManager defaultManager]fileExistsAtPath:strdestination]){
if([[NSFileManager defaultManager]copyItemAtPath:strdestination toPath:toPath error:&Error]==NO){
UIAlertView *Alert=[[UIAlertView alloc]initWithTitle:@"copy" message:[NSString stringWithFormat:@"%@",Error] delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[Alert show];
}
else{
UIAlertView *Alert=[[UIAlertView alloc]initWithTitle:@"Not copy" message:[NSString stringWithFormat:@"%@",Error] delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[Alert show];
}
}
Estou recebendo o logotipo de erro:
Domínio de erro = NSCocoaErrorDominCode = 516 "A operação não pôde ser concluída. (Cacau seta 516.)" userInfo = 0x681abf0
NSUnderlyingError = 0x681b920 "A operação não pôde ser concluída. O arquivo existe"
pasta abc não há nome da música "sg.mp3", mas eu ainda estou recebendo o erro de arquivo existe. Eu não sei onde eu cometi erros?