반응형
목표
main.js에서 파일 데이터를 추가하게 되면, list의 수정이 아주 빈번해질 것이다. 따라서 Nodejs를 이용하여 data폴더 안에 파일 목록을 알아내보자.
Google에 nodejs file list in directory 검색해보자.
fs.readdir
//nodedir.js
const testFolder = './data'; //data폴더 안에 있는 파일들을 본다
var fs = require('fs');
fs.readdir(testFolder, function(err, filelist) {
console.log(filelist);
});
반응형
'Back-End > Node.js' 카테고리의 다른 글
Node.js.25.1.JavaScript 함수의 기본 문법 (0) | 2020.09.02 |
---|---|
Node.js.24.App 제작-글목록 출력하기 (0) | 2020.09.01 |
Node.js.22.JavaScript-배열과 반복문 (0) | 2020.09.01 |
Node.js.21.JavaScript-배열 (0) | 2020.09.01 |
Node.js.20.JavaScript-반복문 (0) | 2020.09.01 |