📜  复制文件并使用 fs 粘贴 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:49.687000             🧑  作者: Mango

代码示例2
'use strict';

import fs from 'fs';

let fileContent = 'Anything what you want';
let message = fs.writeFileSync('message.txt', fileContent);

function copyContent(fileName: string, dest: string): boolean {
  try {
    fs.copyFileSync(fileName, dest);
    console.log(dest);
    return true;
  } catch (err) {
    return false;
  }
}

console.log(copyContent('message.txt', 'destination.txt'));