My program performs a search on a specific directory and returns a list of files with specific criteria. I want the user to be able to select an item in the list and click a button and have that file open...is this possible? The first column of my list gives the file name and the second column gives the file path (without the name). Below is the code I have tried - when I run it and try selecting a file and clicking a button, nothing happens - no errors or anything, but the file doesn't open...any suggestions?
Private Sub OpenBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenBtn.Click For Each file As ListViewItem In FilesList.Items Dim filePath As String = file.SubItems(1).Text & "\" & file.Text If file.Selected = True Then MessageBox.Show("You are about to open " & filePath & ". Are you sure?", "Open File", MessageBoxButtons.YesNo, MessageBoxIcon.Information) If DialogResult.Yes Then IO.File.Open(filePath, FileMode.Open) ElseIf DialogResult.No Then MsgBox("you decided not to open") End If End If Next End Sub