NSFileManager を使用して、copyItemAtPath を使用して 1 つのファイル (ディレクトリ) をある場所から別の場所にコピーすると、エラーが発生します。
コードは次のとおりです。
[[NSFileManager defaultManager]copyItemAtPath:@"/Users/name/Documents/localhost/websiteDesign/_Software/" toPath:@"/Volumes/NAME/" error:&handleError];
NSLog(@"%@", [handleError description]);
エラーは次のとおりです。
Error Domain=NSCocoaErrorDomain Code=516 "“_Software” couldn’t be copied to “Volumes” because an item with the same name already exists." UserInfo=0x102842d00
{NSSourceFilePathErrorKey=/Users/name/Documents/localhost/websiteDesign/_Software/, NSUserStringVariant=(Copy), NSDestinationFilePath=/Volumes/NAME/, NSFilePath=/Users/name/Documents/localhost/websiteDesign/_Software/, NSUnderlyingError=0x10283f8e0 "The operation couldn’t be completed. File exists"}
ただし、@"/Volumes/NAME/" である宛先ファイルの名前を @"/Volumes/aaa/" のような名前に変更すると、エラーはなくなります。何故かはわからない。ありがとう !!