我有一个列表框,它读取预定义目录中的所有文件。在这个目录中是各种文件。我想要的是仅“过滤”PDF文件,以便仅在列表框中显示带有.pdf扩展名的文件
我该怎么做呢?
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' make a reference to a directory
Dim di As New IO.DirectoryInfo("c:\")
Dim diar1 As IO.FileInfo() = di.GetFiles()
Dim dra As IO.FileInfo
'list the names of all files in the specified directory
For Each dra In diar1
ListBox1.Items.Add(dra)
Next
End Sub