Reputation: 10683
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.
Upvotes: 1
Views: 7187
Reputation: 3352
First: EISDIR means "error! target is a dir"(i guess), about the error
Second: ncp is what you need i guess
Upvotes: 4