i want to get those log files of particular date from a folder that contains the word error in the l

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I want those text files(log files) in a folder that is created today that has name as something20130416 and which has the word error only in the last 5 lines of it. I need to get those files in an array or list. I am completely new to VB and dont know how to search that particular word and then put those particular log files in an array. Can anyone help me. My code so far is:
Class Program
Public Shared Sub Main(ByVal args As String())
Try
Dim temp As String = ""
Dim log_files() As String = Directory.GetFiles("C:Documents and Settings557137DesktopSampleFolder", DateTime.Today.ToString("*yyyyMMdd") & ".log")
For Each filesfound As String In log_files
Dim contents = IO.File.ReadAllLines(filesfound)
For counter As Integer = contents.Length - 1 To 5 Step -1
If contents.Contains("error") Then
temp &= filesfound
Console.WriteLine("the files: ", temp)

End If
Next
Next
Catch e As Exception
MessageBox.Show("Error", e.Message)
End Try
End Sub
End class

View the full article
 
Back
Top