Created
July 28, 2018 23:16
-
-
Save lfsmoura/98609ac252568d45aa127cd0798624a7 to your computer and use it in GitHub Desktop.
File exists, confirm dialog, Electron
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fileExists(path) { | |
try { | |
return fs.statSync(path); | |
} catch (e) { | |
return false; | |
} | |
} | |
const exist = fileExists(path); | |
if (exist) { | |
const response = dialog.showMessageBox({ | |
type: 'info', | |
buttons: ['Sim', 'Não'], | |
message: 'Já existe um arquivo aqui. Você tem certeza que deseja substituí-lo?', | |
}); | |
if (response !== 1) { | |
return; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment