Answers for "node js copy file to another directory"


copy text from file to another file in javascript with fs

'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);
    return true;
  } catch (err) {
    return false;

console.log(copyContent('message.txt', 'destination.txt'));
Posted by: Guest on December-01-2020

Code answers related to "node js copy file to another directory"

Code answers related to "Javascript"

Browse Popular Code Answers by Language