如何解决尝试将文件从手机的文件系统移动到本地项目文件夹时出错
所以我使用 react-native-fs 和 react-native-document-picker 从文件系统中获取文件并尝试将其复制到我的本地项目。
const handleManifest = async () => {
try {
await DocumentPicker.pick({
type: [DocumentPicker.types.allFiles],}).then(manifestBinaryFile =>
RNFS.moveFile(manifestBinaryFile.uri,'src/Manifests/' + manifestBinaryFile.name).then(result =>{
console.log("FILE MOVED!");
})
})
} catch (err) {
if (DocumentPicker.isCancel(err)) {
// User cancelled the picker,exit any dialogs or menus and move on
console.log(`User cancel the picker. Refreshed app or closed window.`)
} else {
alert("Random error: " + err);
}
}
};
所以这个想法是使用文档选择器从手机的本地文件系统中获取二进制文件(这是有效的),然后使用 RNFS.moveFile 将其从我从中获取的路径(URI)中移动文档选择器到我的本地项目。但是,我收到此错误:
错误:ENOENT:打开失败:ENOENT(没有那个文件或目录),打开'src/Manifests/slick.bin'
当我尝试在本地项目中使用文件夹的绝对路径时,它也不起作用。我也尝试使用 RNFS.copyFile
任何帮助/建议将不胜感激。谢谢
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。