How to select a directory with native desktop API in electron APP¶
dialog.showOpenDialog
can help.
Code example¶
const { dialog } = require('electron')
const selectDirectory = async () => {
const result = await dialog.showOpenDialog(null, {
properties: ['openDirectory']
})
if (result.canceled) {
return null
} else {
const dir = result.filePaths[0]
return dir
}
}
This article is originally created by tooli.top. Please indicate the source when reprinting : https://www.tooli.top/posts/electron_select_directory
Posted on 2023-05-04
Mail to author