zl程序教程

您现在的位置是:首页 >  其他

当前栏目

文件遍历排序函数

2023-06-13 09:13:46 时间
<%

functionbianli(path)

"initiate
path=server.mappath(path)
setfso=server.CreateObject("scripting.filesystemobject")
setobjFolder=fso.GetFolder(path)
setobjfiles=objfolder.files

"把文件名及文件路经存入theFiles数组
intslot=0
DimtheFiles()
redimtheFiles(50)
foreachobjFileinobjFiles
filename=objFile.name
filePath=split(objFile.path,"docs\")
thepath1="./docs/"
thepath=thepath1&filepath(1)
theFiles(slot)=filename&"**"&thepath
slot=slot+1
ifslot>UBound(theFiles)then
ReDimPreservetheFiles(Slot+20)
endif
next
ReDimPreservetheFiles(slot)


"冒泡排序
fori=0toUBound(theFiles)-2
forj=i+1toUBound(theFiles)-1
ifstrComp(theFiles(i),theFiles(j))=1then
tmp=theFiles(i)
theFiles(i)=theFiles(j)
theFiles(j)=tmp
endif
next
next

"输出
fori=0toUBound(theFiles)-1
para=theFiles(i)
filename=split(para,"**",-1,1)(0)
filepath=split(para,"**",-1,1)(1)
%>
<palign="left">
---<imgsrc="../../images/arrow_orange.gif"width="14"height="11">
<ahref="<%=filepath%>"><spanclass="activelink_yellow"><%=filename%></span></a>
</p>
<%
next
endfunction
%>