Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supply a default file extension in the save dialog #23

Closed
briandk opened this issue Feb 13, 2017 · 0 comments
Closed

Supply a default file extension in the save dialog #23

briandk opened this issue Feb 13, 2017 · 0 comments

Comments

@briandk
Copy link
Owner

briandk commented Feb 13, 2017

var fs = require('fs'); // require only if you don't already have it

function saveFile () {
  dialog.showSaveDialog({ filters: [
     { name: 'text', extensions: ['txt'] } //  this is where the magic happens 
    ]}, function (fileName) {
    if (fileName === undefined) return;
    fs.writeFile(fileName, document.getElementById("editor").value, function (err) {   
    });
  }); 
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant