Electron "will-download" not dowloading file in respective path


#1

Hi,

I am using download-item in my render process.
Irrespective of what ever location i choose it is storing in downloads only.
How change this behavior user can store their file in any location

Even If i remove this no effect item.setSavePath(finalFilePath) still file saved in downloads

const {win} = require('electron').remote;
const {webContents} = require("electron").remote.getCurrentWebContents();
const {dialog} = require('electron').remote;
var whereToDownload = dialog.showOpenDialog({properties: ['openDirectory']});
console.log(whereToDownload)


    webContents.session.on("will-download", function(event, item, webContents) {

        var finalFilePath =   whereToDownload+"/"+item.getFilename();
    console.log(finalFilePath) // This show correct path desktop

    item.setSavePath(finalFilePath)
            console.log(item.getTotalBytes());

            item.on('updated', function() {
                console.log('Received bytes: ' + item.getReceivedBytes());
            });
            item.on('done', function(e, state) {
                if (state == "completed") {
                    console.log("Download successfully");
                } else {
                    console.log("Download is cancelled or interrupted that can't be resumed");
                }
            });
    });