Hi Guest 1 HomePage 1 Jobs 1 WalkIn 1Articles  

 :) Latest Topic
Git Tutorial
What is Git?
Features of Git
Benefits of Git
Why use Git?
GitHub Introduction
GitHub Features
GitHub Benefits
Git vs GitHub
Git vs SVN
Git vs Mercurial
Version Control System
Distributed Version Control
Install Git on Windows
Install Git on Linux
Install Git on MAC
Git Environment Setup
Git configuration levels
Git Tools
Git Third Party Tools
Git Terminology Part1
Git Terminology Part2
Git Commands Part1
Git Commands Part2
Git Commands Part3
Git Cheat Sheet
Folders Node.js part2
 


  

 
Folders Node.js part2
Question Posted on 06 Jun 2024

Home >> 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





Other Important Questions
Git Third Party Tools
What is Git?
GitHub Introduction
Features of Git
GitHub Features







 
Top Searches:asp net questions vb net questions sql query uddl questions class javascript Questions sharepoint interview questions and concept silverlight questions and concept wcf questions beans general knowledge ajax questions
PHP | Biztalk | Testing | SAP | HR |