files/en-us/web/api/filesystementry/remove/index.md
{{APIRef("File and Directory Entries API")}}{{Deprecated_Header}}{{Non-standard_Header}}
The {{domxref("FileSystemEntry")}} interface's method
remove() deletes the file
or directory from the file system. Directories must be empty before they can be
removed.
To recursively remove a directory as well as all of its contents and its subdirectories, call {{domxref("FileSystemDirectoryEntry.removeRecursively()")}} instead.
remove(successCallback)
remove(successCallback, errorCallback)
successCallback
errorCallback {{optional_inline}}
None ({{jsxref("undefined")}}).
DOMException.INVALID_MODIFICATION_ERR
DOMException.INVALID_STATE_ERR
DOMException.NO_MODIFICATION_ALLOWED_ERR
DOMException.NOT_FOUND_ERR
DOMException.SECURITY_ERR
This example deletes a temporary work file.
workingDirectory.getFile(
"tmp/work-file.json",
{},
(fileEntry) => {
fileEntry.remove(() => {
/* the file was removed successfully */
});
},
handleError,
);
{{Compat}}