Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

194
Visualizações
electron open default file browser window without returning anything

I am working on an electron app that can open a directory file picker and return a value, like how this question does it: Electron - Open Folder Dialog

ipcMain.on('selectDirectory', function() {

    dir = dialog.showOpenDialog(mainWindow, {

        properties: ['openDirectory']

    });

});

But I cannot find a way to open the folder dialog without returning anything, like if I as a user want to open the location of a file. I don't want to lock my program by waiting for a selected file/folder. I just want a window to a specific location to open on a user's machine through my cross-platform electron app (mac/win/linux)

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Electron's dialog.showOpenDialog() returns a promise, so it would need to be handled as such.

ipcMain.on('selectDirectory', function() {

    // Define the options.
    let options = {
        title: "My title",
        properties: ['openDirectory'],
        defaultPath: "/absolute/path/to/open/at"   // Optional.
    }

    // Show the open (folder) dialog.
    dialog.showOpenDialog(mainWindow, options)
        .then((result) => {
            // Bail early if user cancelled dialog.
            if (result.canceled) { return }

            // Get the selected path.
            let path = result.filePaths[0];

            // More processing...
        })
});

If you wish to set the inital path the dialog opens at then set the defaultPath property.

The path variable will give you the path the user selected in the dialog.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda