威凡网全力打造:网页编程、软件开发编程、平面设计、服务器端开发、操作系统等在线学习平台!学编程,上威凡网!
ASP教程>> ASP基础 应用技巧 数据库相关 ASP类 存储过程 FSO专栏 ASP其他
当前位置:首页 > ASP教程 > FSO专栏
上一节 下一节
 文件遍历排序函数
<%

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


申明:本教程内容由威凡网编辑整理并提供IT程序员分享学习,如文中有侵权行为,请与站长联系(QQ:254677821)!
上一节 下一节
相关教程  
其他教程  
ASP基础
应用技巧
数据库相关
ASP类
存储过程
FSO专栏
ASP其他

违法和不良信息举报中心】邮箱:254677821@qq.com
Copyright©威凡网 版权所有 苏ICP备2023020142号
站长QQ:254677821