Вы читаете английскую версию этой статьи, так как пока нет перевода на данный язык. Помогите нам перевести эту статью!

This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.

This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The FileSystemDirectoryEntry interface's method removeRecursively() removes the directory as well as all of its content, hierarchically iterating over its entire subtree of descendant files and directories.

To remove a single file, or an empty directory, you can also use FileSystemEntry.remove().


FileSystemDirectoryEntry.removeRecursively(successCallback[, errorCallback]);


A function to call once the directory removal process has completed. The callback has no parameters.
errorCallback Optional
A function to be called if an error occurs while attempting to remove the directory subtree. Receives a FileError describing the error which occurred as input.

Return value



If an error occurs and an errorCallback was specified, it gets called with a single parameter: a FileError object describing the error. The FileError.code specifies what type of error occurred, as follows:

An attempt was made to remove the root directory; this is not permitted.
The file system's state doesn't permit modification.
The directory represented by the FileSystemDirectoryEntry no longer exists.
The directory is not accessible; perhaps it's in use by another application or is locked at the operating system level.
The directory could not be removed for security reasons. Possible reasons include:
  • The directory and/or its contents may not be safe to access from a Web application.
  • Too many file system calls are being made.
  • Other security concerns as raised by the user agent or the operating system.

If you try to delete a directory which contains one or more files that can't be removed, or if an error occurs while deletion of a number of files is underway, some files may not be deleted. You should provide an errorCallback to watch for and handle this, perhaps by trying again.


directory.removeRecursively(function() {
  /* The directory was removed successfully */
}, function() {
  /* an error occurred while removing the directory */


Specification Status Comment
File and Directory Entries API
The definition of 'getDirectory()' in that specification.
Draft Now removed from spec!

This API has no official W3C or WHATWG specification.

Browser compatibility

Update compatibility data on GitHub
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
Chrome Full support 13Edge No support NoFirefox No support 50 — 52
No support 50 — 52
Notes While the removeRecursively() method existed, it immediately called the error callback with NS_ERROR_DOM_SECURITY_ERR.
IE No support NoOpera No support NoSafari No support NoWebView Android Full support YesChrome Android Full support YesFirefox Android No support 50 — 52
No support 50 — 52
Notes While the removeRecursively() method existed, it immediately called the error callback with NS_ERROR_DOM_SECURITY_ERR.
Opera Android No support NoSafari iOS No support NoSamsung Internet Android ?


Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
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.

See also