Created
December 28, 2020 11:08
-
-
Save AllanGraves/cb480125764d469b968b9d989e2d7188 to your computer and use it in GitHub Desktop.
Sample code to read file system in React
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as FileSystem from 'expo-file-system'; | |
<Button | |
onPress={() => { | |
let dirToRead = FileSystem.documentDirectory; | |
console.log('Reading :' + dirToRead); | |
FileSystem.readDirectoryAsync('file://' + dirToRead) | |
.then((dir) => { | |
dir.forEach((val) => { | |
console.log('File: ' + val); | |
}); | |
}) | |
.catch(() => { | |
console.log('Error reading directory: ' + dirToRead); | |
}); | |
}} | |
title="click me" | |
/> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment