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

1.3k views Asked by At

Is there a way to set a defined directory path programmatically instead of showing the file explorer with .showDirectoryPicker() for the user to select the actual path?

1

There are 1 answers

2
DenverCoder9 On BEST ANSWER

You need to obtain a handle to your desired root directory once via 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 each time, since once granted permissions are not restored, but must be re-obtained each time, at least for the moment.