Electron Dialog saving file not working

前端 未结 2 1063
闹比i
闹比i 2021-01-14 15:43

Electron version: 1.3.3 Operating system: Ubuntu 14.04

I want to save a XML object into a .xml file with Electron. I try this:

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-14 16:25

    The showSaveDialog() API does not save the file for you. You must use the returned path and use Node to save your file.

    const {dialog} = require("electron").remote;
    const fs = require('fs');
    
    var savePath = dialog.showSaveDialog({});
    
    fs.writeFile(savePath, fileData, function(err) {
        // file saved or err
    });
    

提交回复
热议问题