Node.js: Determine file size on modification

前端 未结 3 1200
深忆病人
深忆病人 2021-01-13 15:11

I\'m watching a file in Node.js and would like to obtain the size of the file each time it changes. How can this be done with fs.watchFile?

This is what

3条回答
  •  一整个雨季
    2021-01-13 15:47

    var fs = require('fs');
    
    fs.watchFile('some.file', function () {
        fs.stat('some.file', function (err, stats) {
            console.log(stats.size);
        });
    });
    

提交回复
热议问题