Selected item in listbox, to form part of a directory

277 views Asked by At

I'm having a hard time trying to check if a file exist when the user selects an item from the listbox. The selected item is supposed to be converted into a part of a directory to open a file. I know for sure I have the right event and that the problem is within the "if" statement because without the "if" statement a message box will show the item name. Its hard to explain in words so heres the code, and if someone finds an answer to this issue and I'm not on, Thanks.

Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged
    Dim item As String = ListBox1.SelectedItem.ToString
    If System.IO.File.Exists(Application.StartupPath & "\" & item & "\" & "config.yml") Then
        Button1.Enabled = True
    End If
End Sub
0

There are 0 answers