Visual Studio 2012 - 用于列出的集合输出?

时间:2013-12-08 17:58:06

标签: vb.net visual-studio-2012 collections

所以基本上我正在尝试创建一个文件管理器,而我却失败了。当我从zip / rar文件加载文件名时,我试图找出并且没有找到关于为什么我得到(Collection)的单一响应。

enter image description here

代码如下

Imports System.IO

Public Class Form1
    Private Sub modFolderButton_Click(sender As Object, e As EventArgs) Handles modFolderButton.Click
        Dim modFolder
        modFolder = modFolderText.Text
        If IO.Directory.Exists(modFolder) Then
            MsgBox("Location Successfully Set; " + modFolder, MsgBoxStyle.Information)
        Else
            MsgBox("Error; Invalid Location Set")
            Exit Sub
        End If
    End Sub

    Private Sub starboundButton_Click(sender As Object, e As EventArgs) Handles starboundButton.Click
        Dim starboundFolder
        starboundFolder = starboundFolderText.Text
        If IO.Directory.Exists(starboundfolder) Then
            MsgBox("Location Successfully Set; " + starboundFolder, MsgBoxStyle.Information)
        Else
            MsgBox("Error; Invalid Location Set")
            Exit Sub
        End If
    End Sub

    Private Sub listRefreshButton_Click(sender As Object, e As EventArgs) Handles listrRefreshButton.Click
        Dim modFolder
        Dim listModsDetected
        modsDetectedList.Items.Clear()
        modFolder = "C:\"
        listModsDetected = My.Computer.FileSystem.GetFiles(modFolder, FileIO.SearchOption.SearchTopLevelOnly, "*.zip")
        modsDetectedList.Items.Add("None Detected!")
        For Each fileName As String In listModsDetected
            modsDetectedList.Items.Remove("None Detected!")
            modsDetectedList.Items.Add(listModsDetected)
        Next
    End Sub
End Class

2 个答案:

答案 0 :(得分:0)

您正在添加:

 modsDetectedList.Items.Add(listModsDetected)

Eho的ToString是它的类型名称。

而是使用modsDetectedList.Items.AddRange(如果存在)或在循环中添加文件名。

答案 1 :(得分:0)

        modsDetectedList.Items.Add(listModsDetected)

您刚刚将收藏品本身添加到了列表中 这就是它显示(collection)的原因。

您可能希望将集合中的每个项目添加到列表中 这就是For EachfileName中为您提供的内容。