admin管理员组

文章数量:1323729

I need to check file existence in the folder like this:

file:///android_asset/contents/my.html

I've tried to use react-native-filesystem plugin

ponentWillMount () {
    async function checkIfFileExists() {
      const fileExists = await FileSystem.fileExists('file:///android_asset/contents/my.html')
      console.log(`file exists: ${fileExists}`)
    }
}

I'm sure that my.html file is there, but I get false in fileExists. Does anybody know how to check it properly?

I need to check file existence in the folder like this:

file:///android_asset/contents/my.html

I've tried to use react-native-filesystem plugin

ponentWillMount () {
    async function checkIfFileExists() {
      const fileExists = await FileSystem.fileExists('file:///android_asset/contents/my.html')
      console.log(`file exists: ${fileExists}`)
    }
}

I'm sure that my.html file is there, but I get false in fileExists. Does anybody know how to check it properly?

Share Improve this question asked Apr 18, 2017 at 11:33 DmitryDmitry 8673 gold badges16 silver badges31 bronze badges 1
  • i think react native has nothing to do with this. what you say. – Hammad Tariq Commented Apr 18, 2017 at 11:53
Add a ment  | 

1 Answer 1

Reset to default 2

Try using react-native-fs.

Looks like they have a function to just what you're looking for: https://github./johanneslumpe/react-native-fs#existsassetsfilepath-string-promiseboolean

本文标签: