Results 1 to 4 of 4

Thread: Finding ONLY directories..

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2000
    Posts
    70

    Question

    Hey guys,
    I'm trying to find ONLY the directories with the Dir() function, i've just found out that specifying vbDirectory returns directories AS WELL AS unattributed files.. does anyone know any way i can return directories only? or even verify whether what the dir function returns is a dir or a file?
    Daniel Rose
    VB 5.0 Enterprise.
    irc:irc2.dynam.ac

    If TheCodeInTheSig() Is Not Lame() Then IDontKnowWhatIs()

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Apr 2000
    Posts
    70

    Bumps it to the top of the list

    c'mon guys someone has to know something
    Daniel Rose
    VB 5.0 Enterprise.
    irc:irc2.dynam.ac

    If TheCodeInTheSig() Is Not Lame() Then IDontKnowWhatIs()

  3. #3
    Addicted Member
    Join Date
    Sep 2000
    Posts
    138
    Please try this:

    Code:
    -------------------------------------------------------
    Option Explicit
    Dim strDir() As String
    Dim strTmp As String
    Dim i As Integer

    Private Sub Form_Load()

    ReDim strDir(i)
    strTmp = Dir("c:\*.*", vbDirectory)
    Do Until strTmp = ""
    If FileLen("c:\" & strTmp) = 0 Then
    strDir(i) = strTmp
    i = i + 1
    ReDim Preserve strDir(i)
    End If
    strTmp = Dir
    Loop
    For i = 0 To UBound(strDir)
    Debug.Print strDir(i)
    Next

    End Sub
    ------------------------------------------------------
    VB 6 Professional

  4. #4
    Hyperactive Member marnitzg's Avatar
    Join Date
    Oct 2000
    Location
    South Africa
    Posts
    372
    Code:
    Private Sub Command1_Click()
    Dim X As String
    Const Pth = "C:\"
    
    X = Dir(Pth, vbDirectory)
    While X <> ""
        If (GetAttr(Pth & X) And vbDirectory) = vbDirectory Then
            List1.AddItem X
        End If
        X = Dir()
    Wend
    End Sub
    This should work.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width