我想发送到客户端文件名和文件创建日期,我试图使用fs.stat提供的出生时间,但我没有看到那里的文件名,所以我的问题,是出生时间是文件创建日期?如何在nodejs中使用文件系统获取文件创建日期?
如何发送文件名和日期创建为json?
app.js
var readDirectory = require('./readDirectory');
app.get('/logs',function(req,res){
readDirectory.readDirectory(function(logFiles){
res.json(logFiles);
});
});
readDirectory.js
var fs = require('fs');
var path = './logs/ditLogs'
function readDirectory(callback){
fs.stat(path, function (err,stats) {
console.log('STATS',stats);
callback(stats);
});
}
exports.readDirectory = readDirectory;
感谢您的信息! – hussain
很高兴帮助你:) – abdulbarik