electron 打开本地文件夹

使用的api为shell.openPath,有些文章会提到shell.openItem,这个方法在electron 9.0后就废弃被openPath替代了。

  • 打开E盘根目录下名为test的文件夹
javascript 复制代码
const { shell } = require('electron')
shell.openPath('E:\\test')

能打开的前提是,E盘根目录下确实有这个文件夹。其次可以发现,我路径上使用的是\\而非/,如果使用/的话,openPath方法会直接报错。

  • 打开当前electron项目根目录下名为src的文件夹
javascript 复制代码
const { app , shell } = require('electron')
shell.openPath(`${app.getAppPath()}\\src`)
相关推荐
柒儿吖7 小时前
Electron for 鸿蒙PC - Webpack PublicPath 动态设置完整方案
webpack·electron·harmonyos
●VON15 小时前
Electron 与鸿蒙 DevEco Studio 的融合实战:从 WebView 到安全 IPC 架构迁移指南
安全·electron
●VON15 小时前
Electron 架构解剖:Chromium + Node.js 如何协同工作
架构·electron·node.js
不爱吃糖的程序媛1 天前
鸿蒙PC Electron 打印服务实现详解
华为·electron·harmonyos
一千柯橘1 天前
Electron 第一步
前端·electron
1024小神1 天前
Electron实现多tab页案例,BrowserView/iframe/webview不同方式的区别
前端·javascript·electron
时间不说谎1 天前
linux上编译electron源码
electron
国服第二切图仔1 天前
Electron for 鸿蒙PC实战案例Gitcode口袋工具之HTTP请求封装的技术实现与设计解析
http·electron·gitcode
weixin79893765432...1 天前
Electron + Vue 3 + Vite 实践
vue.js·electron·vite
●VON2 天前
初识双雄:Electron 与鸿蒙 OS 的跨平台使命
javascript·electron·harmonyos