title: How to show an open file native dialog with Electron?
body: <p>I am trying to add functionality to my Electron app that will allow users to open a file in the app, specifically plain text files. After looking at the Electron documentation, I found <a href="https://electron.atom.io/docs/api/dialog/" rel="noreferrer">this</a> page. I added this code to my <code>app.js</code> file, which I linked to in my <code>index.html</code>.</p>
  
  <pre><code>var fs = require('fs');
  var dialog = require('electron');
  $openFile = $('#openBtn');
  $editor = $('#editor');
  
  $openFile.click(function(){
    dialog.showOpenDialog(function(fileNames) {
      if (fileNames === undefined) return;
      var fileName = fileNames[0];
  
      fs.readFile(fileName, 'utf-8', function (err, data) {
        $editor.val(data);
      });
    });
  });
  </code></pre>
  
  <p>However, when I run this, this error shows up in the console: <code>Uncaught TypeError: dialog.showOpenDialog is not a function</code> I have tried using remote, but to no avail. </p>
  
  <p>Has anyone know how to fix this problem?
  Thanks in advance</p>