【发布时间】:2011-08-12 17:07:26
【问题描述】:
我正在尝试使用 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"
关于我做错了什么有什么想法吗?
提前致谢!
【问题讨论】:
标签: objective-c cocoa nsfilemanager