Imports System.IO
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim path As String
Dim temp As New DirectoryInfo("InitialPathToSearch")
path = SearchFile(temp, "filename.exe")
MsgBox(path)
End Sub
Private Function SearchFile(ByVal SearchDir As DirectoryInfo, ByVal searchFileName As String) As String
Dim temp As String = ""
If SearchDir.GetFiles(searchFileName).Length > 0 Then
Return SearchDir.FullName & "\" & searchFileName
End If
Dim Directories() As DirectoryInfo = SearchDir.GetDirectories("*")
For Each newDir As DirectoryInfo In Directories
temp = SearchFile(newDir, searchFileName)
Next
Return temp
End Function
End Class