如何在Node.js中複製文件?如何複製文件?
例
+ /old
|- image.png
+ /new
我想從 '老' image1.png複製到 '新' 目錄。
這不起作用。
newFile = fs.createWriteStream('./new/image2.png');
oldFile = fs.createReadStream('./old/image1.png');
oldFile.addListener("data", function(chunk) {
newFile.write(chunk);
})
oldFile.addListener("close",function() {
newFile.end();
});
感謝您的回覆!
這裏有什麼嗎? http://nodejs.org/api.html#fs-readstream-152 http://nodejs.org/api.html#fs-writestream-154 – mplungjan 2011-02-12 19:58:19
@mplungjan我剛剛更新了我的問題。 – 2011-02-12 20:02:26
剛剛更新了我的評論;) – mplungjan 2011-02-12 20:03:36