fso文件能否按时间顺序排序!

bybee 2004-11-23 03:03:00
我想备份些文件,我想按文件修改时间排序!

这样我就不用整个文件都循环一遍了!
...全文
186 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
bybee 2004-11-24
  • 打赏
  • 举报
回复
那不还是都得循环一遍!

谢谢各位了!

我现在也是都循环一遍,每次对比下文件修改时间,如果符合我时间条件的我就备份下!
yqh1314 2004-11-23
  • 打赏
  • 举报
回复
fenmixiao() 写的很明确的!
若白师妹 2004-11-23
  • 打赏
  • 举报
回复
呃,其实还是要整个文件都循环一遍
若白师妹 2004-11-23
  • 打赏
  • 举报
回复
冒泡法:
<%
dim folderPath
folderPath = "D:\Inetpub\wwwroot\test" '修改成你要的路径,对这个路径下的文件按日期排列
dim fso,f
set fso=server.CreateObject("Scripting.filesystemobject")
set fld=fso.Getfolder(folderPath)
for each f in fld.files
dd=f.DateLastModified
dd1=year(dd)&"-"&right("0"&month(dd),2)&"-"&right("0"&day(dd),2)&" "
str=str&dd1&f.name&"|"
'response.write f.DateLastModified&f.name &"<br/>"
next
tmp=split(str,"|")
for j=0 to ubound(tmp)
str1=""
for i=0 to ubound(tmp)
if i=ubound(tmp) then exit for
if tmp(i)<=tmp(i+1) then
tt=tmp(i)
tmp(i)=tmp(i+1)
tmp(i+1)=tt
end if
str1=str1&tmp(i)&"|"
next
next
tmp1=split(str1,"|")
for k= 0 to ubound(tmp1)-1
num1=num1+1
response.write num1&". "&tmp1(k)&"<br/>"
next%>
bearzhan88 2004-11-23
  • 打赏
  • 举报
回复
可以
基本思路如下:
定义数组,然后遍里当前文件对象(for each in ****.files),用气泡排序法先排序(比较规则为按什么排就比较什么),逐次给数组赋值,然后输出数组。
fenmixiao 2004-11-23
  • 打赏
  • 举报
回复
我也从网上找的,所以f1.write(...My name is cnbruce)保留下来。
fenmixiao 2004-11-23
  • 打赏
  • 举报
回复
<%
whichfile=Server.MapPath("testfile.txt")
Set fso = CreateObject("Scripting.FileSystemObject")
Set f1 = fso.CreateTextFile(whichfile,true)
f1.Write ("This is a test.My Name is cnbruce.")
f1.Close
Set f2 = fso.GetFile(whichfile)
s = "文件名称:" & f2.name & "<br>"
s = s & "文件短路径名:" & f2.shortPath & "<br>"
s = s & "文件物理地址:" & f2.Path & "<br>"
s = s & "文件属性:" & f2.Attributes & "<br>"
s = s & "文件大小: " & f2.size & "<br>"
s = s & "文件类型: " & f2.type & "<br>"
s = s & "文件创建时间: " & f2.DateCreated & "<br>"
s = s & "最近访问时间: " & f2.DateLastAccessed & "<br>"
s = s & "最近修改时间: " & f2.DateLastModified
response.write(s)
%>
xx123731 2004-11-23
  • 打赏
  • 举报
回复
不知道,帮你顶一下

28,408

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧