Answers for "display files in directory nodejs"

3

how to get file name in directory node js

const fs = require('fs')

const dir = '/Users/flavio/folder'
const files = fs.readdirSync(dir)

for (const file of files) {
  console.log(file)
}
Posted by: Guest on October-16-2020
2

how to get file name in directory node js

const path = require('path')

//...

//inside the `for` loop
const stat = fs.lstatSync(path.join(dir, file))
Posted by: Guest on October-16-2020

Code answers related to "display files in directory nodejs"

Code answers related to "Javascript"

Browse Popular Code Answers by Language