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

1.1k Views Asked by At

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. How can this be performed?

I have used the attribute 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

1

There are 1 best solutions below

0
On

Your code is correct. However, it looks like /ICF-Package is a folder or something, but not a file. copyFileAssets can only copy files, but no folders (and its content)