I'm trying to create a configuration for buttons with electron and shell. To open a file in a determinate location, for example, my file is situated on /Users/***/Desktop/CD-Przemek/documents/QuickStartGuideWN-H1.pdf.
I have already tried the solution inside the electron documentation and works pretty good, but works only on my mac and if I change the file location the button does not work anymore, I'm currently open for any solution. This is my current js code:(on index Html I have only a button)
const openBtn = document.getElementById('openBtn3')
const { shell, app } = require('electron')
const path = require('path');
const fs = require('fs')
openBtn.addEventListener('click', function(event){
shell.openItem('document/documents/QuickStartGuideWN-H1.pdf') //this work really good only in debug mode
//A COUPLE OF SOLUTION TRIED
//var p = path.join(__dirname, '..' 'MAC_drivers')
//shell.openItem(app.getPath("~/Library/Desktop/CD-Przemek/documents/UserGuide.pdfWN-H1.pdf"))
//shell.openItem(app.getPath("desktop") + "/QuickStartGuideWN-H1.pdf")
})
I just need a code that can find the folder or the file on all PCs and on all platforms, and maybe open it. Thanks all