title: Get the array of filenames stored in document directory in React Native
body: <p><strong>CASE</strong></p>
  
  <p>I have downloaded audio files to my document directory under the folder named /tracks/ as :</p>
  
  <pre><code>RNFetchBlob.fs.dirs.DocumentDir + '/tracks/'
  </code></pre>
  
  <p>No doubt I can read each audio by their name as :</p>
  
  <pre><code>RNFetchBlob.fs.dirs.DocumentDir + '/tracks/' + 'audio1.mp3'
  </code></pre>
  
  <p><strong>QUESTION:</strong>
  I want to get the list of all the audios.
  I can see in File Access API , we can read file but I am unable to find how to get the list of audio files from the folder '/tracks/'.</p>
  
  <p>I just want to have an array of filenames in that directory.</p>
  
  <p><strong><em>File Access API link :</em></strong> 
  <a href="https://github.com/wkh237/react-native-fetch-blob/wiki/File-System-Access-API#dirs" rel="nofollow noreferrer">https://github.com/wkh237/react-native-fetch-blob/wiki/File-System-Access-API#dirs</a></p>
  
  <p>P.S: I didn't want to go for other file access plugins.
  I don't know if I have to search other libraries for file listing .</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>With the following code:</p>
  
  <pre><code>var TRACK_FOLDER = RNFetchBlob.fs.dirs.DocumentDir + '/tracks/';
  
  console.log('Files LIST in Tracks Folder = ', RNFetchBlob.fs.ls(TRACK_FOLDER));
  </code></pre>
  
  <p>OUTPUT IS :</p>
  
  <p><a href="https://i.stack.imgur.com/BSXPn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BSXPn.png" alt="Screenshot of Google console"></a></p>
  
  <p>I think I'm getting close but's output seems difficult to parse.
  :(</p>
  
  <p>FINALLY:(this is the way how it is done)</p>
  
  <pre><code>    var TRACK_FOLDER = RNFetchBlob.fs.dirs.DocumentDir + '/tracks/';
  
      console.log('Files list in TRACK_FOLDER = ', RNFetchBlob.fs.ls(TRACK_FOLDER));
  
       RNFetchBlob.fs.ls(TRACK_FOLDER)
      .then( (files) =&gt;{ 
          console.log(files.length);  
          console.log(files); 
          console.log(files[0]); 
  
      })
  </code></pre>
  
  <p>OUTPUT: 
  <a href="https://i.stack.imgur.com/XE18N.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XE18N.png" alt="final output"></a></p>
  
  <p>Hope this helps somebody out there.</p>