copy a file and paste with fs
const fs = require('fs');
// File destination.txt will be created or overwritten by default.
fs.copyFile('source.txt', 'destination.txt', (err) => {
if (err) throw err;
console.log('source.txt was copied to destination.txt');
});
'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'));
Also in JavaScript:
- node js event emitter
- how to push mutual array elements in an array nested loop javascript
- how to remove 000webhost watermark 2019
- javascrip check if string contains substring
- .map function
- atob nodejs
- javascript check if a value is an int
- c# beautify json string
- post json in flutter
- java script functions
- get last item in array
- javascript modal show
- ionic ngfor in component
- import modal bootstrap react
- ngx-translate angular 11
- indexing string in javascript
- swift convert array to json
- datatable dropdown toggle not working
- use jsx html
- turn number into array javascript
- Exception in thread "main" org.openqa.selenium.JavascriptException:
- react json object pretty
- js detect all images errors
- javascript remove object key