Instructions for the fs.readdirSync method in node.js

  • 2020-05-05 10:56:00
  • OfStack

method description:

Synchronous version of fs.readdir ().

Method returns an array object containing the names of all files in the specified directory.

syntax:


fs.readdirSync(path)

Since this method belongs to the fs module, the fs module (var fs= require(" fs "))

needs to be introduced before use

receive parameters:

path   directory path

Example:


var fs = require('fs');
var readDir = fs.readdirSync('readdirtest11');
console.log(readDir);

source:


fs.readdirSync = function(path) {
  nullCheck(path);
  return binding.readdir(pathModule._makeLong(path));
};


Related articles: