我想使用copyItemAtPath複製目錄,但每次失敗時都會出現「操作無法完成。文件存在」錯誤。copyItemAtPath總是失敗,並存在文件存在錯誤
下面是我使用的日誌
NSLog(@"Copying from: %@ to: %@", [[NSUserDefaults standardUserDefaults] objectForKey:@"template_1_path"], path);
if(![file_manager copyItemAtPath:[NSString stringWithFormat:@"%@", [[NSUserDefaults standardUserDefaults] objectForKey:@"template_1_path"]] toPath:[NSString stringWithFormat:@"%@", path] error:&error]) {
NSLog(@"%@" [error localizedDescription]);
}
示例代碼 -
"Copying from: /Users/testuser/Sites/example_site to: /Users/testuser/Desktop"
"The operation couldn’t be completed. File exists"
什麼我做錯了任何想法?
在此先感謝!
這對於moveItemAtPath也是如此:...和moveItemAtURL:... – LaborEtArs 2016-05-13 13:34:10