|
-
Jan 10th, 2001, 03:58 AM
#1
Thread Starter
New Member
I want help with some code to search all folders in a directory....
-
Jan 10th, 2001, 05:07 AM
#2
Fanatic Member
Search folders for what? Specific file, files or text in file(s)?
-
Jan 10th, 2001, 06:08 AM
#3
Thread Starter
New Member
I want to search for tif-files on the cd in all folders...
-
Jan 10th, 2001, 06:18 AM
#4
Searches for *.mp3 in C: but this can be changed easily...
Code:
'objects
'1 cmd button
'1 list box
'*********************
Private Sub Command1_Click()
List1.Clear
Me.MousePointer = vbHourglass
GetAllDirsFrom "c:"
Me.MousePointer = vbNormal
End Sub
Private Function GetAllDirsFrom(ByVal pstrDir As String)
Dim fso As FileSystemObject
Dim fldrMain As Folder
Dim fldrsSub As Folders
Dim fldr As Folder
Set fso = CreateObject("Scripting.FileSystemObject")
Set fldrMain = fso.GetFolder(pstrDir & "\")
If Right(fldrMain.Path, 1) = "\" Then
AddAllFilesFrom Left(fldrMain.Path, Len(fldrMain.Path) - 1)
Else
AddAllFilesFrom fldrMain.Path
End If
' Recurse subdirectories
Set fldrsSub = fldrMain.SubFolders
For Each fldr In fldrsSub
GetAllDirsFrom fldr.Path
Next
DoEvents
End Function
Private Function AddAllFilesFrom(ByVal pstrDir As String)
strFile = pstrDir & "\" & Dir(pstrDir & "\*.mp3")
Do Until strFile = pstrDir & "\"
List1.AddItem strFile
strFile = pstrDir & "\" & Dir
Loop
End Function
hope this helps
~~~~~~~~~~
~~Chenko~~
~~~~~~~~~~
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
|