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

js
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.

options Optional

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:

recursive Optional

Một giá trị boolean, mặc định là false. Khi đặt thành true, 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ệ

NoModificationAllowedError DOMException

Được ném ra nếu trạng thái PermissionStatus.state củ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.

NotFoundError DOMException

Được ném ra nếu mục hiện tại không được tìm thấy.

Ví dụ

js
const dirHandle = await window.showDirectoryPicker();
await dirHandle.removeEntry("app.tmp");

Thông số kỹ thuật

Specification
File System
# api-filesystemdirectoryhandle-removeentry

Tương thích trình duyệt

Xem thêm