Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons

© 2026 BraveProgrammer. All rights reserved.

  1. Courses
  2. /
  3. Electron.js Desktop App Development

Lesson 6 of 28 · javascript

Native Dialogs – Open & Save Files

Duration: 9 mins

Native Dialogs – Open & Save Files

Electron's dialog module opens OS‑native file/folder pickers.

const { dialog } = require('electron');

// Open a file picker (allow multiple)
async function pickFiles(){
  const { canceled, filePaths } = await dialog.showOpenDialog({
    title: 'Select a file',
    properties: ['openFile', 'multiSelections']
  });
  if (!canceled) return filePaths; // array of selected paths
}

// Save dialog
async function pickSave(){
  const { canceled, filePath } = await dialog.showSaveDialog({
    title: 'Save as',
    defaultPath: 'untitled.txt'
  });
  if (!canceled) return filePath;
}

You can call these functions from the main process or via the preload bridge.

Previous: Security Best PracticesNext: System Notifications