【发布时间】:2014-06-17 14:55:37
【问题描述】:
我试图了解为什么我不能使用.GetFiles 返回多个文件扩展名。
这是我当前的代码,运行良好。
'Returns only the filenames based on the directory that is selected
Dim fi = From f In New IO.DirectoryInfo(FolderBrowserDialog1.SelectedPath).GetFiles("*.txt").Cast(Of IO.FileInfo)() _
Order By f.CreationTime
Select f
For Each fileInfo As System.IO.FileInfo In fi
ListBoxFileAvailable.Items.Add(fileInfo.Name)
Next
当我运行它时,我的列表框只填充了 *.txt 文件。
这是代码,如果我添加 ("*.txt, *.xlsx") 并再次运行代码,我的列表框中没有填充任何内容。
'Returns only the filenames based on the directory that is selected
Dim fi = From f In New IO.DirectoryInfo(FolderBrowserDialog1.SelectedPath).GetFiles("*.txt, *.xlsx").Cast(Of IO.FileInfo)() _
Order By f.CreationTime
Select f
For Each fileInfo As System.IO.FileInfo In fi
ListBoxFileAvailable.Items.Add(fileInfo.Name)
Next
如何在我的列表框中添加多个文件扩展名?
【问题讨论】:
标签: vb.net listbox file-extension