This is an experimental technologyCheck the Browser compatibility table carefully before using this in production.
The FileSystemDirectoryEntry
interface of the File and Directory Entries API represents a directory in a file system. It provides methods which make it possible to access and manipulate the files in a directory, as well as to access the entries within the directory.
Basic concepts
You can create a new directory by calling getDirectory()
. If you want to create subdirectories, create each child directory in sequence. If you try creating a directory using a full path that includes parent directories that do not exist yet, an error is returned. So create the hierarchy by recursively adding a new path after creating the parent directory.
Example
In the following code snippet, we create a directory called "Documents."
// Taking care of the browser-specific prefixes.
window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem;
window.directoryEntry = window.directoryEntry || window.webkitDirectoryEntry;
...
function onFs(fs){
fs.root.getDirectory('Documents', {create:true}, function(directoryEntry){
//directoryEntry.isFile === false
//directoryEntry.isDirectory === true
//directoryEntry.name === 'Documents'
//directoryEntry.fullPath === '/Documents'
}, onError);
}
// Opening a file system with temporary storage
window.requestFileSystem(TEMPORARY, 1024*1024 /*1MB*/, onFs, onError);
Properties
This interface has no properties of its own, but inherits properties from its parent interface, FileSystemEntry
.
Methods
This interface inherits methods from its parent interface, FileSystemEntry
.
createReader()
- Creates a
FileSystemDirectoryReader
object which can be used to read the entries in this directory. getDirectory()
- Returns a
FileSystemDirectoryEntry
object representing a directory located at a given path, relative to the directory on which the method is called. getFile()
- Returns a
FileSystemFileEntry
object representing a file located within the directory's hierarchy, given a path relative to the directory on which the method is called.
Obsolete methods
removeRecursively()
- Deletes a directory and all of its contents, including the contents of subdirectories. This has been removed from the spec.
Specifications
Specification | Status | Comment |
---|---|---|
File and Directory Entries APIThe definition of 'FileSystemDirectoryEntry' in that specification. | Draft |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Chrome Full support 8 Full support 8 Alternate Name' Uses the non-standard name: |
Edge Full support 79 Full support 79 Prefixed' Implemented with the vendor prefix: webkit |
Firefox
Full support 50 |
IE
No support No |
Opera Full support Yes Full support Yes Prefixed' Implemented with the vendor prefix: webkit |
Safari
Full support 11.1 |
WebView Android Full support ≤37 Full support ≤37 Alternate Name' Uses the non-standard name: |
Chrome Android Full support 18 Full support 18 Alternate Name' Uses the non-standard name: |
Firefox Android
Full support 50 |
Opera Android
No support No |
Safari iOS
Full support 11.3 |
Samsung Internet Android Full support 1.0 Full support 1.0 Alternate Name' Uses the non-standard name: |
Chrome
Full support 13 |
Edge
Full support 79 |
Firefox
Full support 50 |
IE
No support No |
Opera
No support No |
Safari
Full support 11.1 |
WebView Android
Full support ≤37 |
Chrome Android
Full support 18 |
Firefox Android
Full support 50 |
Opera Android
No support No |
Safari iOS
Full support 11.3 |
Samsung Internet Android
Full support 1.0 | |
Chrome
Full support 8 |
Edge
Full support 79 |
Firefox Full support 50 Full support 50 Notes' In Firefox, the |
IE
No support No |
Opera
No support No |
Safari
Full support 11.1 |
WebView Android
Full support ≤37 |
Chrome Android
Full support 18 |
Firefox Android Full support 50 Full support 50 Notes' In Firefox, the |
Opera Android
No support No |
Safari iOS
Full support 11.3 |
Samsung Internet Android
Full support 1.0 | |
Chrome
Full support 8 |
Edge
Full support 79 |
Firefox Full support 50 Full support 50 Notes' In Firefox, the |
IE
No support No |
Opera
No support No |
Safari
Full support 11.1 |
WebView Android
Full support ≤37 |
Chrome Android
Full support 18 |
Firefox Android Full support 50 Full support 50 Notes' In Firefox, the |
Opera Android
No support No |
Safari iOS
Full support 11.3 |
Samsung Internet Android
Full support 1.0 | |
Chrome
Full support 8 |
Edge
Full support 79 |
Firefox No support 50 — 52 No support 50 — 52 Notes' While the |
IE
No support No |
Opera
No support No |
Safari
No support No |
WebView Android
Full support ≤37 |
Chrome Android
Full support 18 |
Firefox Android No support 50 — 52 No support 50 — 52 Notes' While the |
Opera Android
No support No |
Safari iOS
No support No |
Samsung Internet Android
Full support 1.0 |
Legend
- Full support
- Full support
- No support
- No support
- Experimental. Expect behavior to change in the future.'
- Experimental. Expect behavior to change in the future.
- Non-standard. Expect poor cross-browser support.'
- Non-standard. Expect poor cross-browser support.
- Deprecated. Not for use in new websites.'
- Deprecated. Not for use in new websites.
- See implementation notes.'
- See implementation notes.
- Uses a non-standard name.'
- Uses a non-standard name.
- Requires a vendor prefix or different name for use.'
- Requires a vendor prefix or different name for use.
See also
- File and Directory Entries API
- Introduction to the File System API
FileSystemDirectoryReader
FileSystemEntry
FileSystemFileEntry
FileSystemDirectoryEntry by Mozilla Contributors is licensed under CC-BY-SA 2.5.