我想把当前文件夹下的所有子文件夹列出来,可是里面的文件也都列出来了,谁能帮帮我谢谢! 
这是代码 
    Private Sub Button1_Click( ByVal sender As System.Object, ByVal& ;nbs p;e As System.EventArgs) Handles Button1 .Click 
        Dim MyN ame As String 
        MyName  = Dir(CurDir() + "\", FileAttribute.Dire ctory) 
        Do Whil e MyName <> "" 
             ListBox1.Items.Add(MyName) 
             MyName = Dir() 
        Loop 
    End Sub

解决方案 »

  1.   

    标准答案来了:
    Private Sub Button1_Click( ByVal sender As System.Object, ByVal& ;nbs p;e As System.EventArgs) Handles Button1 .Click 
            Dim MyName As String
            MyName = Dir("c:\", vbDirectory)
            Do While MyName <> ""
                If (GetAttr("c:\" & MyName) And vbDirectory) = vbDirectory Then
                    ListBox1.Items.Add(MyName)
                End If
                MyName = Dir()
            Loop
    End Sub
      

  2.   

    If (GetAttr("c:\" & MyName) And vbDirectory) = vbDirectory Then 这句改成
    If GetAttr("c:\" & MyName) And vbDirectory Then
      

  3.   

    GetAttr("c:\" & MyName) And vbDirectory