目录和子目录中的文件清单

时间:2018-10-09 17:25:22

标签: list file directory

我正在使用以下代码。但是它无法在文本框t1中传递输出。

Imports System.IO

Public Class Form1
Dim fp As String

Private Sub b1_Click(sender As Object, e As EventArgs) Handles b1.Click
    If (FolderBrowserDialog1.ShowDialog() = DialogResult.OK) Then
        fp = FolderBrowserDialog1.SelectedPath
        t2.Text = fp
    End If

End Sub

Private Sub b2_Click(sender As Object, e As EventArgs) Handles b2.Click
    Dim filelist As String() = Directory.GetFiles(fp, SearchOption.AllDirectories)

    For Each filename As String In filelist
        t1.AppendText(filename)
    Next

End Sub

我无法找到错误所在。需要帮助 谢谢

1 个答案:

答案 0 :(得分:0)

我发现愚蠢的事情是在GetFiles中插入文件类型,即“ ”。