Saturday, 31 August 2013

Is it possible to sort items in FSO with classic asp?

Is it possible to sort items in FSO with classic asp?

Im using the following code on an old IIS machine to generate XML for a
mobile app I have built for android and ios devices... it works, but I am
now wanting to figure out how I would go about SORTING by date last
modified so the list has the NEWEST files at top... my question is, based
on how I have my code structured below,
is this possible with my existing code ( sorting 'x' somehow? )?
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%Response.ContentType = "text/xml"%>
<%Response.AddHeader "Content-Type","text/xml"%>
<songlist>
<%
dim fs,fo,x
dim i
set fs=Server.CreateObject("Scripting.FileSystemObject")
'point to a specific folder on the server to get files listing from...
set fo=fs.GetFolder(Server.MapPath("./songs"))
i = -1
for each x in fo.files
'loop through all the files found, use var 'i' as a counter for each...
i = i + 1
'only get files where the extension is 'mp3' -- we only want the mp3 files
to show in list...
if right(x,3) = "mp3" then
%>
<song>
<songid><%=i%></songid>
<name><%= replace(replace(x.Name, "-", " "), ".mp3", "")%></name>
<filename><%=x.Name%></filename>
<datemodified><%=x.DateLastModified%></datemodified>
</song>
<%
end if
next
set fo=nothing
set fs=nothing
%>
</songlist>

No comments:

Post a Comment