This article mainly introduces node. fs. readdirSync method usage instructions. This article introduces fs. readdirSync method description, syntax, receive parameters, use instances, and implement Source Code. For more information, see
Method description:
The synchronous version of fs. readdir ().
The method returns an array object containing "names of all objects in the specified directory.
Syntax:
The Code is as follows:
Fs. readdirSync (path)
Because this method belongs to the fs module, we need to introduce the fs module (var fs = require ("fs") before use "))
Receiving parameters:
Path directory path
Example:
The Code is as follows:
Var fs = require ('fs ');
Var readDir = fs. readdirSync ('readdirtest11 ');
Console. log (readDir );
Source code:
The Code is as follows:
Fs. readdirSync = function (path ){
NullCheck (path );
Return binding. readdir (pathModule. _ makeLong (path ));
};