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`)
相关推荐
逸铭6 小时前
Day 2:10 分钟搭 Electron + Vite + Vue 3——AnchorChat 的第一个窗口
electron·客户端
阿里云云原生1 天前
破局 Electron 监控盲区:基于 WASM 与 IPC 桥接的零侵入可观测 SDK 设计
electron
TrisighT2 天前
Electron 跑在鸿蒙 PC 上,单窗口和多窗口内存差 800MB?我抓了 5 组数据
性能优化·electron·harmonyos
怕浪猫6 天前
Electron 开发实战(十六):总结与展望|生态现状、框架对比、行业趋势与学习指南
前端·javascript·electron
古德new7 天前
鸿蒙PC使用electron迁移:Joplin Electron 桌面适配全记录
华为·electron·harmonyos
三声三视7 天前
Electron 在鸿蒙 PC 上跑 webview,我是怎么把首屏从 4.2s 干到 1.1s 的
华为·electron·harmonyos·鸿蒙
「、皓子~8 天前
海狸IM 2.0 正式发布:六端齐发,开源 IM 迈入新阶段
flutter·electron·开源软件·ai编程·交友·im
JOJO数据科学8 天前
JupyterLab Electron 鸿蒙 PC 适配全记录:从 Python 原生崩溃到 node-static 本地工作台
python·electron·harmonyos
悟空瞎说8 天前
深度排查:Electron MAS 包播放 HDR 视频引发界面卡死问题全解析
electron
不良使8 天前
鸿蒙PC迁移:使用Electron`logseq-master-ohos` 鸿蒙适配全记录
jvm·electron·harmonyos