Question:

How will you read a directory?

Answer:

Following is the syntax of the method to read a directory:

fs.readdir(path, callback)

Parameters

Here is the description of the parameters used:

  • path - This is the directory name including path.

  • callback - This is the callback function which gets two arguments (err, files) where files is an array of the names of the files in the directory excluding '.' and '..'.


Keywords:

© 2017 QuizBucket.org