dim folderPath
folderPath = Server.MapPath("images/") '修改成你要的路径,对这个路径下的文件按日期排列
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/>"
i=i+1
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
下面是我自己写的一段。不过感觉速度有点慢!!
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("E:\jpg")
'列出文件
Set fc = f.Files
dim LastestFileName
dim LastFileDate
LastFileDate="2000-11-12 20:12:04"
For Each f1 in fc
if (Cstr(f1.datelastmodified) > LastFileDate) then
LastFileDate=f1.datelastmodified
LastestFileName=f1.name
end if
<%
dim folderPath
folderPath = Server.MapPath("images/") '修改成你要的路径,对这个路径下的文件按日期排列
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%>