我正在尝试将文件从一个路径移动到另一个路径的目录。我手上有代码。但是,它无法正常工作。我不知道该代码有什么问题。
if ([[NSFileManager defaultManager] moveItemAtPath:"path to be moved" toPath:"destination path" error:&error]) {
NSLog(@"Moved");
} else {
NSLog(@"Not moved:%@", [error localizedDescription]);
}
实际上,如果移动过程成功,将会打印“Moved”。但结果打印错误消息“操作无法完成。(Cocoa错误512。)”。请帮助我摆脱这个问题。提前致谢。
最佳答案
使用下面的函数
[[NSFileManager defaultManager] copyItemAtPath:mainBundleFilePath
toPath:destPath
error:&err]
有关更多信息,请查看下面的帖子,
iPhone - copying a file from resources to Documents gives an error
关于iPhone sdk - 将文件移动到目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5935398/