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`)
相关推荐
_AaronWong2 天前
实现 Electron 资源下载与更新:实时进度监控
前端·electron
alphageek82 天前
Electron开源库入门教程:跨平台桌面应用框架
javascript·其他·electron·开源
xiaoyan20153 天前
Electron38-Winchat聊天系统|vite7+electron38+vue3电脑端聊天Exe
vue.js·electron·vite
槿泽4 天前
Vue集成Electron目前最新版本
前端·vue.js·electron
LDM>W<5 天前
Electron下载失败
前端·javascript·electron
EndingCoder5 天前
Electron 新特性:2025 版本更新解读
前端·javascript·缓存·electron·前端框架·node.js·桌面端
小圣贤君6 天前
小说创作中的时间轴体验设计:事序图交互与用户体验优化
electron·vue·甘特图·时序图·写作软件
ayaya_mana6 天前
BilldDesk:基于Vue3+WebRTC+Nodejs+Electron的开源远程桌面控制
electron·开源·webrtc
卸任6 天前
Electron运行环境判断(是否在虚拟机中)
前端·react.js·electron
F2E_zeke6 天前
使用electron将vue3网页项目包装成pc客户端
javascript·vue.js·electron