I'm getting the folder names, and getting the pdf files at the same directory, and listing both in the same listbox with this code:
Private Sub frmBooks_Load(sender As Object, e As EventArgs) Handles MyBase.Load
For Each folder As String In System.IO.Directory.GetDirectories(Application.StartupPath & "\Books")
ListBox1.Items.Add(Path.GetFileName(folder))
Next
For Each file As String In System.IO.Directory.GetFiles(Application.StartupPath & "\Books\", "*.pdf")
ListBox1.Items.Add(Path.GetFileNameWithoutExtension(file))
Next
BOTH are MIXED and SORTED in the same listbox1 Then i add axacropdf (PDF component) to read pdf files. How can i open/get the path from selected item at listbox to open at axacropdf??
(axacropdf.src =)
This code check if the file exist as .pdf
Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged
If File.Exists(Application.StartupPath & "\Books\" & ListBox1.SelectedItem.ToString & ".pdf") = True Then
AxAcroPDF1.src = (Application.StartupPath & "\Books\" & ListBox1.SelectedItem.ToString & ".pdf")
end if
end sub