Window: showDirectoryPicker() method


目录

The showDirectoryPicker() method of the Window interface displays a directory picker which allows the user to select a directory.

Syntax

showDirectoryPicker()
showDirectoryPicker(options)

Parameters

Return value

A Promise whose fulfillment handler receives a FileSystemDirectoryHandle object.

Exceptions

Security

Transient user activation is required. The user has to interact with the page or a UI element in order for this feature to work.

Examples

This asynchronous function shows a directory picker and returns a FileSystemDirectoryHandle once selected.

async function getDir() {
  const dirHandle = await window.showDirectoryPicker();

  // run code for dirHandle
}

Specifications

Browser compatibility

See also


版本号 #3
由 壳壳虫 创建于 2026-10-31 03:27:53 UTC
由 cocobook-sync 更新于 2026-11-04 17:35:22 UTC