Get Last Modified File from Folder

Here is sample code to get last modified file from folder

Dim directory As DirectoryInfo = New DirectoryInfo(“C:\Temp”)
Dim filter As String = txtFileName.Text

If directory.GetFiles(txtFileName.Text).Count > 0 Then
    Dim myFile As FileInfo = directory.GetFiles(filter).OrderByDescending(Function(f) f.LastWriteTime).First()
    MsgBox(myFile.Name)
Else
    MsgBox(“No files found”)
End If