过时
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.

这是 实验性技术
检查 浏览器兼容性表格 要小心谨慎在生产中使用这之前。

FileSystemDirectoryEntry 接口方法 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]);
					

参数

successCallback

A function to call once the directory removal process has completed. The callback has no parameters.

errorCallback 可选
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.

返回值

undefined .

错误

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:

FileError.INVALID_MODIFICATION_ERR

An attempt was made to remove the root directory; this is not permitted.

FileError.NO_MODIFICATION_ALLOWED_ERR

The file system's state doesn't permit modification.

FileError.NOT_FOUND_ERR
The directory represented by the FileSystemDirectoryEntry no longer exists.
FileError.NOT_READABLE_ERR

The directory is not accessible; perhaps it's in use by another application or is locked at the operating system level.

FileError.SECURITY_ERR
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 */
});
					

浏览器兼容性

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. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
removeRecursively 弃用 非标 Chrome 8 Edge 79 Firefox 50 — 52
不支持 50 — 52
While the removeRecursively() method existed, it immediately called the error callback with NS_ERROR_DOM_SECURITY_ERR .
IE No Opera No Safari No WebView Android ≤37 Chrome Android 18 Firefox Android 50 — 52
不支持 50 — 52
While the removeRecursively() method existed, it immediately called the error callback with NS_ERROR_DOM_SECURITY_ERR .
Opera Android No Safari iOS No Samsung Internet Android Yes

图例

完整支持

完整支持

不支持

不支持

非标。预期跨浏览器支持较差。

非标。预期跨浏览器支持较差。

弃用。不要用于新网站。

弃用。不要用于新网站。

见实现注意事项。

另请参阅

元数据

  • 最后修改: