Stick
Dec 30th, 1999, 02:37 AM
I need to Add All Files and FOLDERS into a List box from a defined dir.
How would i do this ?
Aaron Young
Dec 30th, 1999, 03:06 AM
The easiest way would be to use a Directory and File Listbox, otherwise you can Recurse the Directories yourself with the Dir Function, ie.
Private Sub Command1_Click()
List1.Clear
Call RecurseDir(InputBox("Enter Start Directory..", "List Dir/File", "C:\"))
End Sub
Private Sub RecurseDir(ByVal sStartIn As String)
Dim sDirs() As String
Dim iDirs As Integer
Dim sDir As String
If Right(sStartIn, 1) <> "\" Then sStartIn = sStartIn & "\"
sDir = Dir(sStartIn & "*", vbDirectory + vbHidden + vbNormal + vbReadOnly + vbSystem)
While Len(sDir)
If (GetAttr(sStartIn & sDir) And vbDirectory) = vbDirectory Then
If Left(sDir, 1) <> "." Then
ReDim Preserve sDirs(iDirs)
sDirs(iDirs) = sDir
iDirs = iDirs + 1
End If
ElseIf Left(sDir, 1) <> "." Then
List1.AddItem sStartIn & sDir
End If
sDir = Dir
Wend
For iDirs = 0 To iDirs - 1
Call RecurseDir(sStartIn & sDirs(iDirs))
Next
End Sub
------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
ajyoung@pressenter.com