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`)
相关推荐
怕浪猫3 天前
Electron 开发实战(十六):总结与展望|生态现状、框架对比、行业趋势与学习指南
前端·javascript·electron
古德new4 天前
鸿蒙PC使用electron迁移:Joplin Electron 桌面适配全记录
华为·electron·harmonyos
三声三视4 天前
Electron 在鸿蒙 PC 上跑 webview,我是怎么把首屏从 4.2s 干到 1.1s 的
华为·electron·harmonyos·鸿蒙
「、皓子~5 天前
海狸IM 2.0 正式发布:六端齐发,开源 IM 迈入新阶段
flutter·electron·开源软件·ai编程·交友·im
JOJO数据科学5 天前
JupyterLab Electron 鸿蒙 PC 适配全记录:从 Python 原生崩溃到 node-static 本地工作台
python·electron·harmonyos
悟空瞎说5 天前
深度排查:Electron MAS 包播放 HDR 视频引发界面卡死问题全解析
electron
不良使5 天前
鸿蒙PC迁移:使用Electron`logseq-master-ohos` 鸿蒙适配全记录
jvm·electron·harmonyos
JOJO数据科学5 天前
pgAdmin4 Electron 鸿蒙 PC 适配全记录:从白屏到连接 PostgreSQL
postgresql·electron·harmonyos
「、皓子~5 天前
海狸IM 2.0 开放能力说明:OAuth2 接入与群推送机器人
人工智能·架构·electron·机器人·开源·交友·im
小鹏linux5 天前
鸿蒙PC使用 Electron 迁移:LX Music 桌面版适配全记录
华为·electron·harmonyos