循环文件夹和子文件夹.net

时间:2015-08-23 15:29:36

标签: vb.net directory subdirectory

    Dim txtbx As String = "E:\_net_programs\test"
    For Each d As String In Directory.GetDirectories(txtbx)
        'For Each di As file
        'Next
        'MessageBox.Show(d)
        'Dim folder As DirectoryInfo in directory
    Next

请帮我循环一下这个文件夹" E:_net_programs \ test"并打开每个子文件夹

1 个答案:

答案 0 :(得分:1)

有代码:

Dim txtbx As String = "E:\_net_programs\test"

For Each File In Directory.GetFiles(txtbx, "*", SearchOption.AllDirectories)
    MsgBox(File)
Next

如果您不希望StringFileInfo的循环能够获取其属性(名称,父目录,扩展名等),则代码为:

Dim txtbx As String = "E:\_net_programs\test"

For Each File As FileInfo In New DirectoryInfo(txtbx).GetFiles("*", SearchOption.AllDirectories)
    MsgBox(File.FullName)
Next