存取本機檔案
使用 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');
});使用原生對話框取得檔案路徑
Last updated