Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iPhone sdk-将文件移动到目录_Iphone_Ios4_File Manager - Fatal编程技术网

iPhone sdk-将文件移动到目录

iPhone sdk-将文件移动到目录,iphone,ios4,file-manager,Iphone,Ios4,File Manager,我正在尝试将文件从一个路径移动到另一个路径的目录。我手头有密码。但是,它不能正常工作。我不知道那个密码有什么问题 if ([[NSFileManager defaultManager] moveItemAtPath:"path to be moved" toPath:"destination path" error:&error]) { NSLog(@"Moved"); } else { NSLog(@"Not moved:%@", [error localizedDes

我正在尝试将文件从一个路径移动到另一个路径的目录。我手头有密码。但是,它不能正常工作。我不知道那个密码有什么问题

if ([[NSFileManager defaultManager] moveItemAtPath:"path to be moved" toPath:"destination path" error:&error]) {
    NSLog(@"Moved");
} else {
    NSLog(@"Not moved:%@", [error localizedDescription]);
}  

实际上,如果移动过程成功,将打印“移动”。但结果会打印错误消息“操作无法完成。(Cocoa错误512)。”。请帮我解决这个问题。提前谢谢

使用以下功能

[[NSFileManager defaultManager] copyItemAtPath:mainBundleFilePath 
                                        toPath:destPath 
                                         error:&err]
有关更多信息,请查看下面的SO帖子


尝试copyItemAtPath:toPath:error:而不是moveItemAtPath:toPath:error:,实际上我没有从mainBundle中移动文件。我必须将所选文件从文档目录移动到所选文件夹。如果使用“copyItemAtPath:”,则会显示错误消息“操作无法完成”。文件存在“@Developer:查看以下内容,因此post@Developer:很高兴知道它能帮助您