fs.readdirSync(path[,
options])
This
method returns an array of filenames excluding '.' and '..'.
Below
table summarizes the arguments of readdirSync method.
Argument
|
Type
|
Description
|
||||||
path
|
string
or Buffer or URL
|
Specify
the path of the directory to list the contents for.
|
||||||
options
|
string
or Object
|
Below
table summarizes different options.
|
var fs = require('fs'); var path = 'C:\\Users\\Public\\demo'; var fileNames = fs.readdirSync(path); console.log(fileNames);
Above
script, return all the file names in the directory 'C:\\Users\\Public\\demo'.
No comments:
Post a Comment