tkaragiris posted on May 05, 2010 11:20

Ever had a log file which logs events. The log file is usually appended to which makes displaying it in descending order difficult. This VB.net function takes the log file and reverses the order and displays the most recent lines at the top.
Function ReturnLogInDescOrder(ByVal LogFilePath As String) As String
' Read all lines from a text file and display in reverse order
Dim strArray() As String = System.IO.File.ReadAllLines(LogFilePath)
Dim strTemp As String = ""
Array.Reverse(strArray)
For Each _string As String In strArray
strTemp &= _string & "<br />"
Next
Return strTemp
End Function