路径(比如下载数据默认存放在安装目录下)

实现方法

const { app } = require("electron").remote
const path = require ('path');

// 获取安装目录(也就是文件安装目录中exe文件的目录)
let homeDir =  path.dirname(app.getPath('exe'))

 

Index.html 中获取方式:

<script>
const { remote } = require('electron');
var path = require('path');
var exePath = path.dirname(remote.app.getPath('exe'));
console.log(exePath);
</script>

 

Index.js 中获取方式

 

const { app } = electron;
var path = require('path');
var exePath = path.dirname(app.getPath('exe'));
console.log(exePath);

 

相关文章:

  • 2022-12-23
  • 2021-11-04
  • 2021-08-07
  • 2021-10-09
  • 2021-12-15
  • 2021-08-07
猜你喜欢
  • 2021-12-22
  • 2021-12-03
  • 2021-10-07
  • 2022-12-23
  • 2021-12-17
  • 2021-08-13
  • 2022-12-23
相关资源
相似解决方案