当前位置: 移动技术网 > IT编程>开发语言>Asp > 文件遍历排序函数

文件遍历排序函数

2017年12月12日  | 移动技术网IT编程  | 我要评论
<%

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
%>

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网