Node.js modules built fs of readdir way to view the contents of a folder which contains the file

fs.readdir(path[, options], callback)

Example:

"use strict";
const fs = require("fs");
const path = require("path");

// get the current file absolute path of
the let path.resolve filepath = ();
fs.readdir (filepath, "UTF-. 8", function (ERR, Files) {
  IF (ERR) {
    the console.log (ERR);
  } {the else
    the console.log (Files);
  }
});

Note: The second parameter is not written, then the default is "utf-8"

 

Guess you like

Origin www.cnblogs.com/hros/p/10994700.html