var fs = require('fs');
var path = require('path');
//解析需要遍历的文件夹,我这以E盘根目录为例
var filePath = path.resolve('E:');
//调用文件遍历方法
fileDisplay(filePath);
/**
* 文件遍历方法
* @param filePath 需要遍历的文件路径
*/
function fileDisplay(filePath){
//根据文件路径读取文件,返回文件列表
fs.readdir(filePath,function(err,files){
if(err){
console.warn(err)
}else{
//遍历读取到的文件列表
files.forEach(function(filename){
//获取当前文件的绝对路径
var filedir = path.join(filePath,filename);
//根据文件路径获取文件信息,返回一个fs.Stats对象
fs.stat(filedir,function(eror,stats){
if(eror){
console.warn('获取文件stats失败');
}else{
var isFile = stats.isFile();//是文件
var isDir = stats.isDirectory();//是文件夹
if(isFile){
console.log(filedir);
}
if(isDir){
fileDisplay(filedir);//递归,如果是文件夹,就继续遍历该文件夹下面的文件
}
}
})
});
}
});
}
E:\jars\spring-framework-4.2.9.RELEASE\docs\javadoc-api\org\springframework\cache\interceptor\AbstractCacheInvoker.html E:\jars\spring-framework-4.2.9.RELEASE\docs\javadoc-api\org\springframework\cache\interceptor\AbstractCacheResolver.html E:\jars\spring-framework-4.2.9.RELEASE\docs\javadoc-api\org\springframework\cache\interceptor\BasicOperation.html E:\jars\spring-framework-4.2.9.RELEASE\docs\javadoc-api\org\springframework\cache\interceptor\CacheableOperation.html E:\jars\spring-framework-4.2.9.RELEASE\docs\javadoc-api\org\springframework\cache\interceptor\BeanFactoryCacheOperationSourceAdvisor.html E:\jars\spring-framework-4.2.9.RELEASE\docs\javadoc-api\org\springframework\cache\interceptor\AbstractFallbackCacheOperationSource.html E:\jars\spring-framework-4.2.9.RELEASE\docs\javadoc-api\org\springframework\cache\interceptor\CacheAspectSupport.CacheOperationContext.html E:\jars\spring-framework-4.2.9.RELEASE\docs\javadoc-api\org\springframework\cache\interceptor\CacheAspectSupport.html E:\jars\spring-framework-4.2.9.RELEASE\docs\javadoc-api\org\springframework\cache\interceptor\CacheAspectSupport.CacheOperationMetadata.html E:\jars\spring-framework-4.2.9.RELEASE\docs\javadoc-api\org\springframework\cache\interceptor\CacheErrorHandler.html E:\jars\spring-framework-4.2.9.RELEASE\docs\javadoc-api\org\springframework\cache\interceptor\CacheEvictOperation.html E:\jars\spring-framework-4.2.9.RELEASE\docs\javadoc-api\org\springframework\cache\interceptor\CacheInterceptor.html E:\jars\spring-framework-4.2.9.RELEASE\docs\javadoc-api\org\springframework\cache\interceptor\CacheOperation.html E:\jars\spring-framework-4.2.9.RELEASE\docs\javadoc-api\org\springframework\cache\interceptor\CacheOperationInvocationContext.html E:\jars\spring-framework-4.2.9.RELEASE\docs\javadoc-api\org\springframework\cache\interceptor\CacheOperationInvoker.html ············
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有