colezpapa3
Programmer
I want to load all the subdirectories and files from each subdirectory into a table - so I can load 'em into a list box for a user to select.
Problem is my ParseFolders routine is loading all the subdirectories as separate folders...I dont see them in their proper sequence....Attached is the code.
I am looking to see
Folder
--- subDirectory
files
files
files
--- subDirectory
files
files
Folder
--- subDirectory
...
Sub ParseFolders(objFSO, strPath)
Dim ThisFolder, ThisFolderSubs
Dim intItem As Integer
Dim ctlList As Access.ListBox
Dim x, y, z
Dim objFile As File
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("AllFiles")
Debug.Print strPath
Set ThisFolder = objFSO.GetFolder(strPath)
Set ThisFolderSubs = ThisFolder.SubFolders
For Each objFolder In ThisFolderSubs
x = StrReverse(objFolder)
y = InStr(x, "\")
z = Mid$(x, 1, y)
z = StrReverse(z)
With rs
For Each objFile In objFolder.Files
' Me.ctlList.AddItem objFile.Name
rs.AddNew
rs!SubFolder = z
rs!Filename = objFile.Name
rs.Update
Next
End With
ParseFolders objFSO, objFolder.Path
Next objFolder
Me.ctlList.Requery
Set rs = Nothing
Set db = Nothing
End Sub
Problem is my ParseFolders routine is loading all the subdirectories as separate folders...I dont see them in their proper sequence....Attached is the code.
I am looking to see
Folder
--- subDirectory
files
files
files
--- subDirectory
files
files
Folder
--- subDirectory
...
Sub ParseFolders(objFSO, strPath)
Dim ThisFolder, ThisFolderSubs
Dim intItem As Integer
Dim ctlList As Access.ListBox
Dim x, y, z
Dim objFile As File
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("AllFiles")
Debug.Print strPath
Set ThisFolder = objFSO.GetFolder(strPath)
Set ThisFolderSubs = ThisFolder.SubFolders
For Each objFolder In ThisFolderSubs
x = StrReverse(objFolder)
y = InStr(x, "\")
z = Mid$(x, 1, y)
z = StrReverse(z)
With rs
For Each objFile In objFolder.Files
' Me.ctlList.AddItem objFile.Name
rs.AddNew
rs!SubFolder = z
rs!Filename = objFile.Name
rs.Update
Next
End With
ParseFolders objFSO, objFolder.Path
Next objFolder
Me.ctlList.Requery
Set rs = Nothing
Set db = Nothing
End Sub