vb怎么获得指定目录下所有子目录的目录名??

解决方案 »

  1.   

      Dim   dir   As   New   IO.DirectoryInfo("c:\")   
      Dim   tempdir   As   IO.DirectoryInfo   
      Dim   str   As   String   =   ""   
      For   Each   tempdir   In   dir.GetDirectories()   
              Dim   name   As   String   =   tempdir.FullName   
              str   +=   name   +   vbCrLf   
      Next   
      MsgBox(str)   
        
      '取得文件信息:   
      Dim   dir   As   New   IO.DirectoryInfo("c:\")   
      Dim   f   As   IO.FileInfo   
      Dim   str   As   String   =   ""   
      For   Each   f   In   dir.GetFiles("*.*")   
              Dim   name   As   String   =   f.FullName   
              str   +=   name   +   vbCrLf   
      Next   
      MsgBox(str)   
      

  2.   

    http://topic.csdn.net/t/20020828/15/977325.html
    版权归人家所有,我引用一下。
      

  3.   

     Public Sub HaalDirOp(ByVal Path$)
    Dim vDirName As String, LastDir As String
    Screen.MousePointer = vbHourglass
    If Right(Path$, 1) <> "\" Then Path$ = Path$ & "\"
    vDirName = Dir(Path, vbDirectory) ' Retrieve the first entry.
    Do While Not vDirName = ""
    If vDirName <> "." And vDirName <> ".." Then
    If (GetAttr(Path & vDirName) And vbDirectory) = vbDirectory Then
    LastDir = vDirName
    'MsgBox vDirName
    List1.AddItem Path$ & vDirName
    Call HaalDirOp(Path$ & vDirName)
    vDirName = Dir(Path$, vbDirectory)
    Do Until vDirName = LastDir Or vDirName = ""
    vDirName = Dir
    Loop
    If vDirName = "" Then Exit Do
    End If
    End If
    vDirName = Dir
    Loop
    Screen.MousePointer = vbNormal
    End Sub
    Private Sub Command1_Click()
    HaalDirOp "E:\"
    End Sub 搞定了呵呵。结了