I have a program that creates logfiles, by using the applications name, the date and time and then .log at the end for the logfiles filename.
I want to retrieve a list of these logfiles. So far this successfully retrieves a list of ALL files in the directory, i need to match the name against the applications name and ".log" at the end of the filename. From my research i came up with something like this below, but it doesnt work.
Could someone guide me in the right direction please?
Thanks.
I want to retrieve a list of these logfiles. So far this successfully retrieves a list of ALL files in the directory, i need to match the name against the applications name and ".log" at the end of the filename. From my research i came up with something like this below, but it doesnt work.
Could someone guide me in the right direction please?
Code:
Create a reference to the current running directory.
Dim DirBase As New DirectoryInfo(StartupPath)
Create an array representing the files in the current directory.
Dim fi As FileInfo() = DirBase.GetFiles("*.*")
Print out the names of the files in the current directory.
Dim fiTemp As FileInfo
Create array holding names of all sub-directories
Dim di As DirectoryInfo() = DirBase.GetDirectories("*.*")
For Each fiTemp In fi
MsgBox(fiTemp.Name)
Dim r As New Regex(^(GetExecutingAssembly.GetName.Name) & ".log"$)
Find a single match in the input string.
Dim m As Match = r.Match(fiTemp.Name)
If m.Success Then
.....................
End If
Next
Thanks.