如何用文件名填充组合框?
问题描述:
亲爱的朋友,
晚上好..plz帮帮我..
文件夹包含扩展名为.pdf和.xml的文件集合.
如何获取.xml文件名的集合并在组合框中填充名称?
谁能在vb.net中建议代码?
Dear friends,
good evening..plz help me..
A folder contains collection of files with the extension of .pdf and .xml.
How to get collection of .xml file name and populate the names in combobox?
can anyone suggest a code in vb.net?
答
要获取文件列表,可以使用DirectoryInfo.然后遍历文件名,并将它们一个一个地添加到组合框.
To get the list of file you can use DirectoryInfo. And iterate through the file names and add them to the combobox one by one.
Dim di As New IO.DirectoryInfo("D:\MyFolder")
Dim directoryObject As IO.FileInfo() = di.GetFiles()
Dim fileInfoObject As IO.FileInfo
For Each fileInfoObject In directoryObject
ListBox1.Items.Add(dra)
Next