FileSystemDirectoryHandle: removeEntry() 方法
注意:此功能在 Web Workers 中可用。
removeEntry() 方法是 FileSystemDirectoryHandle 介面的一部分,它會嘗試移除目錄控制代碼中名為指定名稱的檔案或目錄條目。
語法
js
removeEntry(name)
removeEntry(name, options)
引數
name-
一個字串,表示您希望刪除的條目的
FileSystemHandle.name。 options可選-
一個可選物件,包含以下選項:
recursive可選-
一個布林值,預設為
false。當設定為true時,條目將被遞迴刪除。
返回值
一個 Promise,它會以 undefined 解析。
異常
TypeError-
如果名稱不是有效的字串或包含檔案系統不允許的字元,則會丟擲此錯誤。
NotAllowedErrorDOMException-
如果控制代碼的
PermissionStatus.state在readwrite模式下不是'granted',則會丟擲此錯誤。 InvalidModificationErrorDOMException-
如果
recursive設定為 false 且要刪除的條目有子項,則會丟擲此錯誤。 NotFoundErrorDOMException-
如果當前條目未找到,或者指定名稱的條目未找到或不匹配,則會丟擲此錯誤。
示例
下面的示例移除了目錄控制代碼中的一個條目。
js
const entryName = "entryToRemove";
// assuming we have a directory handle: 'currentDirHandle'
currentDirHandle.removeEntry(entryName).then(() => {
// code to run if removing was successful
});
規範
| 規範 |
|---|
| 檔案系統 # api-filesystemdirectoryhandle-removeentry |
瀏覽器相容性
載入中…