FileSystemDirectoryHandle: phương thức removeEntry()
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2023.
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
Note: This feature is available in Web Workers.
Phương thức removeEntry() của giao diện FileSystemDirectoryHandle cố gắng xóa không đồng bộ một mục nếu handle thư mục chứa một tệp hoặc thư mục có tên được chỉ định.
Cú pháp
removeEntry(name)
removeEntry(name, options)
Tham số
name-
Một chuỗi biểu thị tên của mục cần xóa.
optionsOptional-
Một đối tượng tùy chọn chứa các thiết lập cho mục được xóa. Các tùy chọn như sau:
recursiveOptional-
Một giá trị boolean, mặc định là
false. Khi đặt thànhtrue, xóa cả mục và mọi mục con bên trong nó.
Giá trị trả về
Một Promise được thực thi khi việc xóa hoàn tất.
Ngoại lệ
NoModificationAllowedErrorDOMException-
Được ném ra nếu trạng thái
PermissionStatus.statecủa handle không phải là'granted'ở chế độreadwrite. TypeError-
Được ném ra nếu tên được chỉ định không phải là một chuỗi hợp lệ hoặc chứa các ký tự có thể gây xung đột với hệ thống tệp gốc.
NotFoundErrorDOMException-
Được ném ra nếu mục hiện tại không được tìm thấy.
Ví dụ
const dirHandle = await window.showDirectoryPicker();
await dirHandle.removeEntry("app.tmp");
Thông số kỹ thuật
| Specification |
|---|
| File System> # api-filesystemdirectoryhandle-removeentry> |