将文件夹中所有文本文件的内容显示到文本框中 VB

Showing content of all textfiles in folder into a textbox VB

我需要在文本框中显示同一文件夹中多个文本文件的内容。

我现在的代码:

Public Class Form1
    Dim dMods1 = "DirectPathToFolderWithTextFiles"
    Dim dMods2 = "DirectPathToFolderWithTextFiles"
    Dim dMods3 = "DirectPathToFolderWithTextFiles"
    Dim dMods4 = "DirectPathToFolderWithTextFiles"

    Dim fileCount1 As Integer = Directory.GetFiles(dMods1).Length
    Dim fileCount2 As Integer = Directory.GetFiles(dMods2).Length
    Dim fileCount3 As Integer = Directory.GetFiles(dMods3).Length
    Dim fileCount4 As Integer = Directory.GetFiles(dMods4).Length

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim nl = System.Environment.NewLine
        Dim Item = dMods1 & "\*.txt"
        Dim Item2 = dMods1 & "\sada2.txt"
        If Not Item Is Nothing Then

            TextBox2.Text = File.ReadAllText(Item)


        End If

    End Sub
End Class

一个简单的“*.txt”,如 "Item",得到错误 "invalid characters in the path"。如何显示文本框中的内容?或者有更简单的方法吗?

对文件夹中的文件使用 for each 循环

        For Each FilePath As String In System.IO.Directory.GetFiles("C:\Windows")
            If FilePath.ToLower.EndsWith(".txt") Then 
                TextBox1.text &= System.IO.File.ReadAllText(FilePath) & vbNewLine & vbNewLine
            End If
        Next