#Region " Form Load "
Private Sub frmBrowser_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
lbl_SelectedFile.Text = "Selected File:"
LoadTreeView()
End Sub
#End Region
Private Const DUMMY As String = "DUMMY"
Private Enum ItemType
Directory = 1
File = 2
End Enum
Private Sub tvw_Files_Root_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles tvw_Files_Root.AfterSelect
Try
With e.Node
Select Case .Tag
Case ItemType.File
Dim fi As New FileInfo(.FullPath)
DisplayFSIProperties(fi)
Case Else
End Select
End With
Catch exp As Exception
MsgBox(exp.Message, , "after")
MsgBox(exp.TargetSite, , "after")
End Try
End Sub
Private Sub tvw_Files_Root_BeforeExpand(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewCancelEventArgs) Handles tvw_Files_Root.BeforeExpand
Try
e.Node.Nodes.Clear()
AddFolders(e.Node)
AddFiles(e.Node)
Catch exp As IOException
MsgBox(exp.Message, , "before IO")
Catch exp As Exception
MsgBox(exp.Message, , "before exp")
End Try
End Sub
Private Sub AddFiles(ByVal nod As TreeNode)
Dim strPath As String = nod.FullPath
Dim strFile As String
With nod
For Each strFile In Directory.GetFiles(strPath)
With nod.Nodes.Add(Path.GetFileName(strFile))
.Tag = ItemType.File
End With
Next
End With
End Sub
Private Sub AddFolders(ByVal nod As TreeNode)
Dim strPath As String = nod.FullPath
Dim strDir As String
With nod
For Each strDir In Directory.GetDirectories(strPath)
With nod.Nodes.Add(Path.GetFileName(strDir))
.Tag = ItemType.Directory
.Nodes.Add(DUMMY)
End With
Next
End With
End Sub
Private Sub LoadTreeView()
Dim strDrive As String
tvw_Files_Root.Nodes.Clear()
For Each strDrive In Directory.GetLogicalDrives()
With tvw_Files_Root.Nodes.Add(strDrive)
.Nodes.Add(DUMMY)
End With
Next
End Sub
Private Sub DisplayFSIProperties(ByVal fsi As FileSystemInfo)
Me.lbl_SelectedFile.Text = "Selected File: " & fsi.Name
FilePath = fsi.FullName
FileName = fsi.Name
End Sub
Private Sub cmd_cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_cancel.Click
Me.Hide()
End Sub
Private Sub Cmd_ok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cmd_ok.Click
If FilePath = "" Or FileName = "" Then
MsgBox("A file was not selected" & vbCrLf & "Please Select a file", MsgBoxStyle.OKOnly, "No File Selected")
Else
If Male = True Then
MSPRDir = FilePath
MainForm.txt_MaleSPRFile.Text = FileName
MSPRName = FileName
Else
If Female = True Then
FSPRDir = FilePath
MainForm.txt_FemaleSPRFile.Text = FileName
FSPRName = FileName
Else
If Male = False And Male = False Then
GENDir = FilePath
MainForm.txt_Genfile.Text = FileName
GENName = FileName
End If
End If
End If
Me.Hide()
End If
End Sub