- Sub a(ByVal aa As String) 'aa为欲遍历的目录
- Dim d_1, d_2, d_3,d_4 As New ArrayList '定义4个数组,其中d_3为文件夹数组,d_4为所有文件数组
- d_1.AddRange(System.IO.Directory.GetDirectories(aa))
- d_3.AddRange(d_1)
- d_4.addrange(system.io.directory.getfiles(aa)
- Do While d_1.Count >= 1
- For Each d_1_1 As String In d_1
- d_2.AddRange(System.IO.Directory.GetDirectories(d_1_1))
- d_4.addrange(system.io.directory.getfiles(d_1_1)
- Next
- d_3.AddRange(d_2)
- d_1.Clear()
- d_1.AddRange(d_2)
- d_2.Clear()
- Loop
- End Sub
使用 ArrayList 动态数组遍历目录
最新推荐文章于 2024-04-22 23:10:20 发布