Answers for "js get files in directory"

5

node js get files in dir

const path = require('path');
const fs = require('fs');

fs.readdir(
  path.resolve(__dirname, 'MyFolder'),
  (err, files) => {
    if (err) throw err;
    
    for (let file of files) {
      console.log(file);
    }
  }
);
Posted by: Guest on September-07-2020
1

javascript get list of files in directory

var fs = require('fs');
var files = fs.readdirSync('/downloads');
Posted by: Guest on December-08-2020

Code answers related to "js get files in directory"

Code answers related to "Javascript"

Browse Popular Code Answers by Language