VB.NET arraylist显示在一行中

时间:2013-07-10 08:06:49

标签: arrays vb.net arraylist textbox

我尝试制作一个可以显示一行中所有项目的arraylist。

Dim listarray As New ArrayList
Dim JARLIB As String = "*.jar"
Dim dir As New IO.DirectoryInfo(GetFolderPath(SpecialFolder.ApplicationData) & "\.minecraft\libraries\")
Dim diarr1() As IO.FileInfo = dir.GetFiles(JARLIB, SearchOption.AllDirectories)
Dim drar As IO.FileInfo
'list the names of all files in the specified directory
For Each drar In diarr1
    listarray.Add((drar.DirectoryName) & ";")
Next
elemante = listarray.ToString
RichTextBox1.Text = elemante

这不起作用,我必须在TextBox中找到像

这样的东西
C:\User\file.jar;C:\User\file\file2.jar;
你能帮帮我吗?谢谢!

1 个答案:

答案 0 :(得分:1)

listarray.ToString不会返回ArrayList的所有元素。

看起来你想要这样的东西:

Dim listarray As New ArrayList
Dim JARLIB As String = "*.jar"
Dim dir As New IO.DirectoryInfo(GetFolderPath(SpecialFolder.ApplicationData) & "\.minecraft\libraries\")
Dim diarr1() As IO.FileInfo = dir.GetFiles(JARLIB, SearchOption.AllDirectories)
Dim drar As IO.FileInfo
'list the names of all files in the specified directory
For Each drar In diarr1
    listarray.Add((drar.DirectoryName) & ";")
Next
For Each item In listarray
    elemante = elemante & item.ToString
Next
RichTextBox1.Text = elemante