一个文件夹,下面包含很多子目录,想遍历这个文件夹,读取所有子目录内的txt文件,该怎么做?
参考:http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=186470&skin=0
封装成内部函数,拿去用吧Dim lg As New List(Of String)
Dim dlg As New FolderBrowserDialog
If dlg.ShowDialog = DialogResult.Ok Then
Dim path As String = args(0)
Dim ls = args(1)
For Each file As String In FileSys.GetFiles(path)
If file.Contains(".txt") Then
ls.add(file)
End If
Next
For Each p As String In FileSys.GetDirectories(path) '循环调用自身代码
Functions.Execute("文件递归", p, ls)
Next
End If