存取本地文件
使用 fs 模块存取本地文件
fs 模块存取本地文件const fs = require('fs');
// 读取文件
fs.readFile('/path/to/file', (err, data) => {
if (err) throw err;
console.log(data);
});
// 写入文件
fs.writeFile('/path/to/file', 'hello world', (err) => {
if (err) throw err;
console.log('done');
});使用原生对话框取得文件路径
最后更新于