diff --git a/GBM/Forms/frmFileFolderSearch.vb b/GBM/Forms/frmFileFolderSearch.vb index a6f1149..8bf3085 100644 --- a/GBM/Forms/frmFileFolderSearch.vb +++ b/GBM/Forms/frmFileFolderSearch.vb @@ -3,6 +3,7 @@ Imports System.IO Public Class frmFileFolderSearch Private sSearchItem As String + Private sGameName As String = String.Empty Private bIsFolder As Boolean Private sFoundItem As String Private oDrives As List(Of DriveInfo) @@ -12,6 +13,15 @@ Public Class frmFileFolderSearch Delegate Sub UpdateInfoCallBack(ByVal sCurrentFolder As String) + Public Property GameName As String + Get + Return sGameName + End Get + Set(value As String) + sGameName = value + End Set + End Property + Public Property SearchItem As String Get Return sSearchItem @@ -50,17 +60,28 @@ Public Class frmFileFolderSearch Private Function SearchDirectory(ByVal dir As DirectoryInfo, ByVal sDirectoryName As String) As String Dim sSubSearch As String = String.Empty + Dim sFoundItem As String = String.Empty If bwSearch.CancellationPending Then Return "Cancel" End If + 'Ignore Symlinks + If (dir.Attributes And FileAttributes.ReparsePoint) = FileAttributes.ReparsePoint Then + Return String.Empty + End If + UpdateInfo(dir.FullName) Try 'Search Current Directory If dir.GetDirectories(sDirectoryName).Length > 0 Then - Return dir.FullName & Path.DirectorySeparatorChar & sDirectoryName + sFoundItem = dir.FullName & Path.DirectorySeparatorChar & sDirectoryName + If mgrCommon.ShowMessage(mgrPath_ConfirmPathCorrect, New String() {GameName, sFoundItem}, MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then + Return sFoundItem + Else + Return String.Empty + End If End If 'Search Sub Directory @@ -82,26 +103,38 @@ Public Class frmFileFolderSearch Private Function SearchFile(ByVal dir As DirectoryInfo, ByVal sFileName As String) As String Dim sSubSearch As String = String.Empty + Dim sFoundItem As String = String.Empty If bwSearch.CancellationPending Then Return "Cancel" End If + 'Ignore Symlinks + If (dir.Attributes And FileAttributes.ReparsePoint) = FileAttributes.ReparsePoint Then + Return String.Empty + End If + UpdateInfo(dir.FullName) Try 'Search Current Directory If dir.GetFiles(sFileName).Length > 0 Then - Return dir.FullName & Path.DirectorySeparatorChar & sFileName + sFoundItem = Path.GetDirectoryName(dir.FullName & Path.DirectorySeparatorChar & sFileName) + If mgrCommon.ShowMessage(mgrPath_ConfirmPathCorrect, New String() {GameName, sFoundItem}, MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then + Return sFoundItem + Else + Return String.Empty + End If End If 'Search Sub Directory Dim subdirs() As DirectoryInfo = dir.GetDirectories("*") For Each newDir As DirectoryInfo In subdirs - sSubSearch = SearchFile(newDir, sFileName) - If sSubSearch <> String.Empty Then - Return sSubSearch - End If + sSubSearch = SearchFile(newDir, sFileName) + + If sSubSearch <> String.Empty Then + Return sSubSearch + End If Next Catch e As System.UnauthorizedAccessException 'Do Nothing diff --git a/GBM/Managers/mgrPath.vb b/GBM/Managers/mgrPath.vb index a55693a..4f78348 100644 --- a/GBM/Managers/mgrPath.vb +++ b/GBM/Managers/mgrPath.vb @@ -346,6 +346,7 @@ Public Class mgrPath Dim sFolder As String = String.Empty Dim bSearchFailed As Boolean = False + frmFind.GameName = sGameName frmFind.SearchItem = sProcess & ".*" frmFind.FolderSearch = False @@ -366,13 +367,7 @@ Public Class mgrPath frmFind.ShowDialog() If frmFind.FoundItem <> String.Empty Then - sFolder = IO.Path.GetDirectoryName(frmFind.FoundItem) - sMessage = mgrCommon.FormatString(mgrPath_ConfirmPathCorrect, New String() {sGameName, sFolder}) - If mgrCommon.ShowMessage(sMessage, MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then - Return sFolder - Else - sFolder = String.Empty - End If + Return frmFind.FoundItem Else bSearchFailed = True End If @@ -386,6 +381,8 @@ Public Class mgrPath If mgrCommon.ShowMessage(sMessage, MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then sFolder = SetManualgamePath() End If + + frmFind.Dispose() End If Return sFolder