title | short-title | slug | page-type | browser-compat |
---|---|---|---|---|
FileSystemDirectoryHandle: removeEntry() method |
removeEntry() |
Web/API/FileSystemDirectoryHandle/removeEntry |
web-api-instance-method |
api.FileSystemDirectoryHandle.removeEntry |
{{securecontext_header}}{{APIRef("File System API")}}{{AvailableInWorkers}}
The removeEntry()
method of the
{{domxref("FileSystemDirectoryHandle")}} interface attempts to remove an entry if the
directory handle contains a file or directory called the name specified.
removeEntry(name)
removeEntry(name, options)
-
name
- : A string representing the {{domxref('FileSystemHandle.name')}} of the entry you wish to remove.
-
options
{{optional_inline}}-
: An optional object containing options, which are as follows:
recursive
{{optional_inline}}- : A boolean value, which defaults to
false
. When set totrue
entries will be removed recursively.
- : A boolean value, which defaults to
-
A {{jsxref('Promise')}} which resolves with undefined
.
- {{jsxref("TypeError")}}
- : Thrown if the name is not a valid string or contains characters not allowed on the file system.
NotAllowedError
{{domxref("DOMException")}}- : Thrown if the {{domxref('PermissionStatus.state')}} for the handle is not
'granted'
inreadwrite
mode.
- : Thrown if the {{domxref('PermissionStatus.state')}} for the handle is not
InvalidModificationError
{{domxref("DOMException")}}- : Thrown if
recursive
is set to false and the entry to be removed has children.
- : Thrown if
NotFoundError
{{domxref("DOMException")}}- : Thrown if the current entry is not found or if the entry of the specific name is not found or matched.
The following example removes an entry within the directory handle.
const entryName = "entryToRemove";
// assuming we have a directory handle: 'currentDirHandle'
currentDirHandle.removeEntry(entryName).then(() => {
// code to run if removing was successful
});
{{Specifications}}
{{Compat}}