Which fs method would you use to read the contents of a directory?

  • fs.readdir()
  • fs.read()
  • fs.readDir()
  • fs.listDirectory()
To read the contents of a directory in Node.js, you should use the fs.readdir() method. It returns an array of all the file and directory names in the specified directory. The other options are not valid fs methods for this purpose.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *