Answers for "fs get size of file"

1

nodejs get file size

var fs = require("fs"); //Load the filesystem module
var stats = fs.statSync("myfile.txt")
var fileSizeInBytes = stats["size"]
//Convert the file size to megabytes (optional)
var fileSizeInMegabytes = fileSizeInBytes / 1000000.0
Posted by: Guest on August-06-2020
0

get file size from fs.stat

// In bytes

function getFilesizeInBytes(filename) {
    var stats = fs.statSync(filename);
    var fileSizeInBytes = stats.size;
    return fileSizeInBytes;
}
Posted by: Guest on June-21-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language