Results 1 to 5 of 5

Thread: finding if a folder exists

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 1999
    Location
    u.s.a
    Posts
    127
    How could one find out if any subfolders exist in a folder?
    I don't want to find out in a spesific one exists ,rather, find out if any exist im a given folder.
    Thanks.
    Dan.

  2. #2
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Nitro
    Posts
    633
    Dir("Your File", vbdirectory) = ""
    Chemically Formulated As:
    Dr. Nitro

  3. #3
    Guest
    Private Declare Function FindClose Lib "kernel32" (ByVal hFindFile As Long) As Long
    Private Declare Function FindFirstFile Lib "kernel32" Alias "FindFirstFileA" (ByVal lpFileName As String, lpFindFileData As WIN32_FIND_DATA) As Long
    Private Declare Function FindNextFile Lib "kernel32" Alias "FindNextFileA" (ByVal hFindFile As Long, lpFindFileData As WIN32_FIND_DATA) As Long


    Public Function CheckForSubFolders(ByVal sFolder As String) as boolean
    Dim tFD As WIN32_FIND_DATA
    Dim lFile As Long
    Dim bFound As Long
    Dim sFilename As String

    CheckForSubFolders = False
    If Right(sFolder, 1) <> "\" Then sFolder = sFolder & "\"
    lFile = FindFirstFile(sFolder & "*", tFD)
    bFound = lFile
    While bFound
    sFilename = UCase(Left(tFD.cFileName, InStr(tFD.cFileName, Chr(0)) - 1))
    If (tFD.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY) Then
    'If it's a Folder, add it to the Sub Folders Array
    If Left(sFilename, 1) <> "." Then

    CheckforSubFolders = True
    Exit Function
    End If
    End If
    'Find the Next File, (if there is one).
    bFound = FindNextFile(lFile, tFD)
    Wend
    'Close the API Find Handle
    Call FindClose(lFile)
    End Sub

    'call the above function as

    if dir(Foldername,vbdirectory) <> "" then
    if checkforsubfolders(FolderName) then
    msgbox "Sub folders exist"
    else
    msgbox "No subfolders exist"
    end if
    else
    msgbox "Folder does not exist"
    end if

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Sep 1999
    Location
    u.s.a
    Posts
    127
    Nitro – Thanks
    Sarun-Thanks for the replay but you are one seriously disturbed individual.

    Are you a compiler?

    May god have mercy on your soul.

    Thanks again
    Dan.

  5. #5
    Guest
    danab: thank you for your prayers.

    but what is the "replay" issue here ? or did u mean "reply"

    "I don't want to find out in a spesific one exists ,rather, find out if any exist im a given folder."

    i was just wondering the "spesific"s of your post.
    To be honest, there is no answer at all to your question because you are a folder ("im a folder") and what you want is "find out in a spesific one exists"

    LOL



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