I am trying to copy one folder to another using node.js here is folder path:-
D:\\node\\files\\11\\j1_1\\j1_2\\j1_3
I want to copy folder j1_3 to path D:\\node\\files\\11\\j1_1\\
here is my code:-
var source = fs.createReadStream(old);
var dest = fs.createWriteStream(newp);
source.pipe(dest);
source.on('end', function () { /* copied */ });
source.on('error', function (err) {
console.log("hi");
/* error */
});
but I am getting this error:-
events.js:72
throw er; // Unhandled 'error' event
^
Error: EISDIR, open 'D:\node\files\11\j1_1'
I have also try fs.rename function but getting same error.
First: EISDIR means "error! target is a dir"(i guess), about the error
Second: ncp is what you need i guess
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.