isaaclloyd
06-15-2005, 01:41 AM
My hosting service isn't very helpful when it comes to databases so I am trying to get away with using text files. I am working on a script where it reads and displays each textfile in the folder. And so far it works great, however there is one problem that I am hoping someone can help me with. I need it to read and display the "last modified" or "last created" text file FIRST. Here is what I have so far for the script. Any comments or suggestions would greatly be appreciated. Thanks for your time.
~Isaac~
The Script
<%
'======= Parameters =========
myAbsolutePath = Server.MapPath("/test/txt/") ' The absolute path to the dir to list
URLdir = "/test/txt/" 'The Path to My files starting from your web root dir
FileNameExtension = ".txt" 'The file name extension of the files to be listed
'====== End Parameters =======
Function DirFiles (FolderPath, FileNameExtention)
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Folder = FSO.GetFolder(FolderPath)
Set Files = Folder.Files
If Files.Count > 0 Then
For Each nFile In Files
If Right(nFile.Name,4)=FileNameExtention then
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile(Server.MapPath(URLdir & nFile.Name))
Do While Not objTextFile.AtEndOfStream
Response.Write objTextFile.ReadLine & "<BR>" & vbCrLf
Loop
Response.Write "<HR COLOR='#d20000'>"
objTextFile.Close
end if
Next
else
Response.Write "No Messages Found."
End If
Set FSO = nothing
Set Folder = nothing
Set Files = nothing
Set objTextFile = Nothing
Set objFSO = Nothing
End function
DirFiles myAbsolutePath, FileNameExtension
%>
~Isaac~
The Script
<%
'======= Parameters =========
myAbsolutePath = Server.MapPath("/test/txt/") ' The absolute path to the dir to list
URLdir = "/test/txt/" 'The Path to My files starting from your web root dir
FileNameExtension = ".txt" 'The file name extension of the files to be listed
'====== End Parameters =======
Function DirFiles (FolderPath, FileNameExtention)
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Folder = FSO.GetFolder(FolderPath)
Set Files = Folder.Files
If Files.Count > 0 Then
For Each nFile In Files
If Right(nFile.Name,4)=FileNameExtention then
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile(Server.MapPath(URLdir & nFile.Name))
Do While Not objTextFile.AtEndOfStream
Response.Write objTextFile.ReadLine & "<BR>" & vbCrLf
Loop
Response.Write "<HR COLOR='#d20000'>"
objTextFile.Close
end if
Next
else
Response.Write "No Messages Found."
End If
Set FSO = nothing
Set Folder = nothing
Set Files = nothing
Set objTextFile = Nothing
Set objFSO = Nothing
End function
DirFiles myAbsolutePath, FileNameExtension
%>