我正在获取文件夹名称,并在同一目录中获取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 文件。如何打开/获取从列表框中的选定项目到在 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