This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the specification changes.

This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

The FileSystemDirectoryEntry interface's method createReader() returns a FileSystemDirectoryReader object which can be used to read the entries in the directory.


directoryReader = FileSystemDirectoryEntry.createReader();



Return value

A FileSystemDirectoryReader object which can be used to read the directory's entries.


This example creates a method called readDirectory(), which fetches all of the entries in the specified FileSystemDIrectoryEntry and returns them in an array.

function readDirectory(directory) {
  let dirReader = directory.createReader();
  let entries = [];

  let getEntries = function() {
    dirReader.readEntries(function(results) {
      if (results.length) {
        entries = entries.concat(toArray(results));
    }, function(error) {
      /* handle error -- error is a FileError object */

  return entries;

This works by creating an internal function, getEntries(), which calls itself recursively to get all the entries in the directory, concatenating each batch to the array. Each iteration, readEntries() is called to get more entries. When it returns an empty array, the end of the directory has beenr reached, and the recursion ends. Once control is returned to readDirectory(), the array is returned to the caller.


Specification Status Comment
File and Directory Entries API
The definition of 'createDirectory()' in that specification.
Editor's Draft Initial specification.

This API has no official W3C or WHATWG specification.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 13 webkit 50 (50) No support No support No support
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support No support 0.16webkit 50.0 (50) No support No support No support

See also

Document Tags and Contributors

 Contributors to this page: Sheppy
 Last updated by: Sheppy,