Forum Moderators: open
cheers
<%
Function FindLastFile(strFolderUrl)
Dim fso
Dim fld
Dim fil
Dim filLastModified
Dim dateLastModified
Dim tsSet fso = Server.CreateObject("Scripting.FileSystemObject")
'Find Last Modified file in a directory
'Get folder
Set fld = fso.GetFolder(Server.MapPath(strFolderUrl))'walk through files in folder looking
'for last modified file, remember it
'when it is found
dateLastModified = #1/1/100#
For Each fil in fld.files
If fil.DateLastModified > dateLastModified Then
Set filLastModified = fil
dateLastModified = fil.DateLastModified
End If
NextIf Not (filLastModified Is Nothing) Then
'read the remembered file's contents
'to the return value of the function
Set ts = filLastModified.OpenAsTextStream()
FindLastFile = ts.ReadAll()
Call ts.Close()
Set ts = Nothing
Else
FindLastFile = ""
End If
Set fil = Nothing
Set fld = Nothing
Set fso = Nothing
End Function
%>
Then you could display the file with:
<pre>
<%=Server.HTMLEncode(FindLastFile("/_themes/xoc"))%>
</pre>
The basic scheme is to use the Scripting.FileSystemObject object to browse the directory structure. Then when you find the right file, save it. Then open it to a text stream and get its contents to a string and return it.