简体   繁体   English

在 react-native android 项目中,如何将文件夹从资产复制到 DocumentDirectoryPath?

[英]In a react-native android project,How to copy a folder from assets to the DocumentDirectoryPath?

I am using a react-native project in which,I want to copy the contents of a certain folder in assets inside android to RNFS.DocumentDirectoryPath.我正在使用 react-native 项目,我想将 android 内资产中某个文件夹的内容复制到 RNFS.DocumentDirectoryPath。 How can this be performed?如何执行此操作?

I have used the attribute copyFileAssets().我使用了属性 copyFileAssets()。

 copyfile() {
    RNFS.copyFileAssets('/ICF-Package', RNFS.DocumentDirectoryPath + '/ICFPackage').then((result) => console.log('DONE')).catch((error) => console.log(error, 'ERROR'));
  };

  I'm getting the following error:

Error: Asset '/ICF-Package' could not be opened错误:无法打开资产“/ICF-Package”

Your code is correct.你的代码是正确的。 However, it looks like /ICF-Package is a folder or something, but not a file.但是,看起来/ICF-Package是文件夹或其他东西,而不是文件。 copyFileAssets can only copy files, but no folders (and its content) copyFileAssets只能复制文件,不能复制文件夹(及其内容)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 React-native:Android Debug版本不会从react-native assets文件夹加载图像资源 - React-native : Android Debug build does't loads image assets from the react-native assets folder 从DocumentDirectoryPath将本机共享图像反应到Instagram - React Native sharing image to Instagram from DocumentDirectoryPath 如何列出assets文件夹react-native中的文件 - How to list files in assets folder react-native 如何从我的 react-native 项目构建 android apk? - How to build android apk from my react-native project? .如何将文件从项目资产文件夹复制到android studio中的设备数据文件夹? - .How to copy files from project assets folder to device data folder in android studio? VSCode会忽略我在react-native项目中的/ android文件夹 - VSCode ignores my /android folder in react-native project 如何在Android上的TextInput react-native中防止复制到剪贴板? - How to prevent copy to clipboard in TextInput react-native on Android? 如何在 react-native android 项目中更改权限对话框语言? - How to change permission dialog language in the react-native android project? 如何强制 react-native 项目在物理 android 设备上运行? - How to force react-native project to run on a physical android device? 无法从 Android-Studio 构建 react-native 项目 - Cannot build react-native project from Android-Studio
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM