欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

文件遍历排序函数

程序员文章站 2022-05-18 11:37:38
<% function bianli(path) 'initiate path = server.mappath(path) set fso=serv...
<%

function bianli(path)

'initiate
path = server.mappath(path)
set fso=server.createobject("scripting.filesystemobject")
set objfolder=fso.getfolder(path)
set objfiles = objfolder.files

'把文件名及文件路经存入thefiles数组
int slot = 0
dim thefiles()
redim thefiles(50)
for each objfile in objfiles
filename = objfile.name
filepath = split(objfile.path,"docs\")
thepath1 = "./docs/"
thepath = thepath1 & filepath(1)
thefiles(slot) = filename&"**"&thepath
slot = slot + 1
if slot > ubound(thefiles) then
redim preserve thefiles(slot+20)
end if
next
redim preserve thefiles(slot)


'冒泡排序
for i = 0 to ubound(thefiles)-2
for j = i+1 to ubound(thefiles)-1
if strcomp(thefiles(i),thefiles(j)) = 1 then
tmp = thefiles(i)
thefiles(i) = thefiles(j)
thefiles(j) = tmp
end if
next
next

'输出
for i = 0 to ubound(thefiles)-1
para = thefiles(i)
filename = split(para,"**",-1,1)(0)
filepath = split(para,"**",-1,1)(1)
%>
<p align = "left">
---<img src='../../images/arrow_orange.gif' width='14' height='11'>
<a href='<%=filepath%>'><span class="activelink_yellow"><%=filename%></span></a>
</p>
<%
next
end function
%>