从混合列表框加载 axacropdf(pdf 组件)上的文件

Loading file on axacropdf (pdf component) from mixed listbox

我正在获取文件夹名称,并在同一目录中获取 pdf 文件,并使用以下代码将两者列在同一列表框中:

        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

两者在同一个列表框中混合并排序1 然后我添加 axacropdf(PDF 组件)来读取 pdf 文件。 我如何 open/get 从列表框的选定项目到在 axacropdf 打开的路径?

(axacropdf.src =)

此代码检查文件是否以 .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