come per la ricerca all'interno di una cartella, ti crei una funzione ricorsiva da utilizzare per le varie cartelle.
codice:
Public Function FindFile(ByVal nomeFile As String) As String
Dim strDrives() As String = Directory.GetLogicalDrives()
Dim Directories As String()
Dim iDirectory, filePath As String
Dim driveDetails As DriveInfo
For Each drive As String In strDrives
driveDetails = New DriveInfo(drive)
If driveDetails.DriveType.ToString = "Fixed" Then
Directories = Directory.GetDirectories(drive)
For Each iDirectory In Directories
filePath = SearchFile(iDirectory, nomeFile)
If filePath.Length > 0 Then Return filePath
Next
End If
Next
Return String.Empty
End Function
Private Function SearchFile(ByVal Dir As String, ByVal nomeFile As String) As String
Dim Directories As String()
Dim iDirectory As String, filePath As String
SearchFile = String.Empty
Directories = Directory.GetDirectories(Dir)
If File.Exists(Path.Combine(Dir, nomeFile)) Then Return Dir
For Each iDirectory In Directories
filePath = SearchFile(iDirectory, nomeFile)
If filePath.Length > 0 Then Return filePath
Next
End Function