Skip to content

Instantly share code, notes, and snippets.

@AllanGraves
Created December 28, 2020 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AllanGraves/cb480125764d469b968b9d989e2d7188 to your computer and use it in GitHub Desktop.
Save AllanGraves/cb480125764d469b968b9d989e2d7188 to your computer and use it in GitHub Desktop.
Sample code to read file system in React
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