crackyourinterview.com


To improves our performance please Like Share Subscribe(Will boost us)

Folders Node.js part2
Question Posted on 06 Jun 2024Home >> Tutorial >> Git Tutorial >> Folders Node.js part2

Folders Node.js part2

Folders Node.js Part2


Here in this chapter we will read the content of a directory or folder. And here we will do different operation on the folder and files. We use fs.readdir() or fs.readdirSync() or fsPromises.readdir() to read the contents of a directory. And below code reads the content of a folder, files and subfolders and then returns their relative path. Below is the code to return the all files in some specific folder here we use two require first is to get fs module and second is for Path.

Here in below code we have use readdirSync to check all files and name the file as foldertest.js.

To view the code

Download Code


node.js read

And below is the folder and its files details.


Files in folder

Now we open the node.js command prompt and run the below command to execute the command


node foldertest.js


And output of above command is given below:-



Filesoutput
0
0




.


Most Visited Questions:-

Deep Learning Questions Answers
Below are the different Deep Leaning Questions and answer a More...

What is Gulpjs and some multiple choice questions on Gulp
Gulpjs is an open source whihc helps in building Javascript More...

Continuous Integration Questions Answers
Below are the 20 odd questions for CI or Continuous Integra More...

Derived relationships in Association Rule Mining are represented in the form of __________.
Derived relationships in Association Rule Mining are repres More...

Microservices Architecture Questions Answers
Below are the different questions on Microservices Architec More...




Other Important Questions

Git Third Party Tools

What is Git?

GitHub Introduction

Features of Git

GitHub Features






@2014-2022 Crackyourinterview (All rights reserved)
Privacy Policy - Disclaimer - Sitemap