将listbox fileinfo放入另一个列表框中

时间:2016-02-26 07:25:39

标签: vb.net listbox

我有一个列表框lbchannel1,其中包含多个项目,例如c:\testc:\temp。现在我想读取添加到列表框的那些文件夹/路径中的所有文件(不是内容,只是文件名)到另一个名为lbLog的列表框(或者文本框会更好)

该事件在SelectedIndexChanged上。

我已经尝试了一些版本......

        Dim f1 As String()
    f1 = Form2.lbchannel1.Items.Cast(Of String).ToArray
    Dim einfo As New IO.DirectoryInfo(f1)
    For Each item As String In f1
       FileIO.SearchOption.SearchTopLevelOnly, (Form2.tbext1_1.Text))
        lbLog.Items.Add(einfo.Name)
    Next

错误:Value of type 'string()' cannot be converted to 'String'

但我无法让它发挥作用。

我做错了什么?

1 个答案:

答案 0 :(得分:1)

这将为您提供所有路径。 重做它以获得所需的文件名。

def words = []
new File( '/home/workstation/jenkins/params' ).eachLine { line ->
    words << line
}
相关问题