尝试将文件从手机的文件系统移动到本地项目文件夹时出错

问题描述

所以我使用 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 (将#修改为@)