📜  nodejs 复制文件 - Javascript 代码示例

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

代码示例3
'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'));