Node.js fs readdir() read directory content

Description

Node.js fs readdir() read directory content


var fs = require('fs');

console.log('Going to read current directory');
fs.readdir('./', function(err, files){
  if (err) {// w w w  . ja v a 2s .  c o  m
    return console.error(err);
  }
  files.forEach(function(file){
    console.log(file);
  });
});



PreviousNext

Related