I want to copy the image.pngform /folder1in /folder2, how to do it?
image.png
/folder1
/folder2
/folder1 image.png /folder2
Thank!
Try something like this:
var fs = require('fs'); var inStr = fs.createReadStream('/your/path/to/file'); var outStr = fs.createWriteStream('/your/path/to/destination'); inStr.pipe(outStr);
The code is not tested, just written from memory.
Or, if you prefer callbacks:
fs = require('fs') fs.readFile('folder1/image.png', function (err, data) { if (err) throw err; fs.writeFile('folder2/image.png', data, function (err) { if (err) throw err; console.log('It\ saved!'); }); });
Source: https://habr.com/ru/post/1796663/More articles:Released bytes in protocol buffer arrays? - c #Haskell HDBC-Sqlite3 always returns SqlByteString - haskellEntity Framework Basics - c #About Union Unused Fields - cIs it possible to disable the phrase in JTable? - javaAspcompat on ASPX Page - .netMediaElement Windows Phone 7 - windows-phone-7Django: follow relationships back - pythonopenid with appengine - javaSQL Server registration and summary statement - sqlAll Articles