有没有一种方法可以通过文件系统访问以编程方式设置默认目录 API

Is there a way to programmatically set the default directory with File System Access API

有没有办法以编程方式设置定义的目录路径,而不是使用 .showDirectoryPicker() 向用户显示文件资源管理器 select 实际路径?

您每次都需要通过 showDirectoryPicker(). You can from thereon store the handle to the directory in IndexedDB and continue from there, even after a reload. Note, though, that you need to check permissions 获取所需根目录的句柄,因为一旦授予权限就不会恢复,但每次都必须重新获取,至少目前是这样。