Fixes for issue #39

This commit is contained in:
Michael J. Seiferling
2016-03-06 12:06:43 -06:00
parent ca9fef33ea
commit be2335b61e
2 changed files with 43 additions and 13 deletions
+39 -6
View File
@@ -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