目前它编译正确,但是当我运行打开它并单击按钮时,它会将所有文件从 C:\ 添加到 CheckedListBox1 但然后停止...
Imports System.IO
Public Class Form1
Public Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles GetProfiles_Button.Click
Dim rootObject As String() = Directory.GetFiles("C:\")
For Each subObject As String In rootObject
searchObject(subObject)
Next
End Sub
Public Shared Sub searchObject(targetObject As String)
If File.GetAttributes(targetObject) = FileAttributes.Directory Then
Form1.CheckedListBox2.Items.Add(targetObject)
Dim subRoot As String() = Directory.GetFiles(targetObject)
For Each subRootObject As String In subRoot
searchObject(subRootObject)
Next
Else
Form1.CheckedListBox1.Items.Add(targetObject)
End If
End Sub
End Class