Ans come sempre ti ringrazio per l'aiuto. O rivisto il codice del filesearch, è ottimo, unica pecca e che dato che il ciclo For Each directory non si ferma mai, finisce col trovare più di un file con lo stesso nome. Per interromperlo o provato ad utilizzare una message box che ti chiede se il percorso e corretto oppure no, solo che sembra infischiarsene il programma, continuando a cercarmi il file nel ciclo For Each..
codice:
Imports System.IO
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim nomefile As String = "WoW.exe"
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)
Next
End If
Next
End Sub
Private Function SearchFile(ByVal Dir As String, ByVal nomeFile As String) As String
Dim Directories As String()
Dim iDirectory As String, filePath As String
Dim risposta As MsgBoxResult
SearchFile = String.Empty
Directories = Directory.GetDirectories(Dir)
For Each iDirectory In Directories
filePath = SearchFile(iDirectory, nomeFile)
If File.Exists(Path.Combine(Dir, nomeFile)) Then
risposta = MsgBox("Il percorso è corretto? " + (Dir + "\" + nomeFile), MsgBoxStyle.YesNo, "Controllo path del gioco....")
If risposta = MsgBoxResult.Yes Then
Exit For
Else
End If
TextBox1.Text = (Dir)
End If
Next
End Function
End Class