Method description:
Synchronous version of fs.readdir() .
The method returns an array object containing "all file names in the specified directory".
grammar:
The code copy is as follows:
fs.readdirSync(path)
Since this method belongs to the fs module, it is necessary to introduce the fs module before use (var fs= require("fs") )
Receive parameters:
path directory path
example:
The code copy is as follows:
var fs = require('fs');
var readDir = fs.readdirSync('readdirtest11');
console.log(readDir);
Source code:
The code copy is as follows:
fs.readdirSync = function(path) {
nullCheck(path);
return binding.readdir(pathModule._makeLong(path));
};