问题描述:
并把文件数量保存到戚扮帆一个变量里面
谢谢
解析缺谈:
function ShowFolderFileList(folderspec)
{
var fso, f, f1, fc, s
fso = new ActiveXObject("Scripting.FileSystemObject")
f = fso.GetFolder(folderspec)
fc = new Enumerator(f.files)
s = ""
for (!fc.atEnd()fc.moveNext())
{
s += fc.item()
s += "<br>"
}
return(s)
}
多设置一个变量来计数就可以了。
function findSync(startPath) {
隐冲 let result=[]
明咐 function finder(path) {
let files=fs.readdirSync(path)
files.forEach((val,index) =>{
let fPath=join(path,val)
let stats=fs.statSync(fPath)
if(stats.isDirectory()) finder(fPath)
if(stats.isFile()) result.push(fPath)
})
}
finder(startPath)
激携纯 return result
}
let fileNames=findSync('./')
javascript如卜颤山何读取文件名洞宴例如:<from action='sql.asp' name="sql_form"> <input type=hidden name="folder_list"></form><script>document.sql_form.folder_list.value=ShowFolderList(part)document.sql_form.submit()////folderspec 参数,返回哪个型中路径下的文件夹function ShowFolderList(folderspec){ var fso, f, fc, s fso = new ActiveXObject("Scripting.FileSystemObject") f = fso.GetFolder(folderspec) fc = new Enumerator(f.SubFolders) s = "" for (!fc.atEnd()fc.moveNext()) { s += fc.item() s += "<br>" } return(s)}</script>你参考一下欢迎分享,转载请注明来源:内存溢出
评论列表(0条)