|
-
Jul 28th, 2000, 05:33 PM
#1
Thread Starter
Lively Member
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.
-
Jul 28th, 2000, 06:39 PM
#2
Fanatic Member
Dir("Your File", vbdirectory) = ""
Chemically Formulated As:
Dr. Nitro
-
Jul 31st, 2000, 12:29 PM
#3
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
-
Jul 31st, 2000, 01:52 PM
#4
Thread Starter
Lively Member
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.
-
Jul 31st, 2000, 02:05 PM
#5
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|