Hello scripters,
I’m stuck here with a problem and I kope someone can point me in the right direction.
What I need is a list of all 3dm files within a folder and all of its subfolders.
The file list should be an array to use in a Listbox.
There are a number of examples to find online but they all print the file names one by one. That won’t do it for me. I need an array…
I tried this:
Dim aFiles(), i 'declared outside the subs
Sub Test1()
i = 0
Redim aFiles(0)
Recurse("D:\Test")
Call Rhino.ListBox (aFiles)
End Sub
Sub Recurse(sPath)
Dim objFile, objSubFolder
Dim filesys : set filesys = CreateObject("Scripting.FileSystemObject")
Dim objFolder : set objFolder = filesys.GetFolder(sPath)
For Each objFile In objFolder.Files
If UCase(filesys.GetExtensionName(objFile.Name)) = "3DM" Then
Redim Preserve aFiles(i)
aFiles(i) = objfile.Name
i = i + 1
End If
Next
For Each objSubFolder In objFolder.SubFolders
Recurse objSubFolder
Next
End Sub
Unfortunately it doesn’t work.
I wonder if its even possible to declare a dynamic array outside a sub and redim it in a sub.
If it’s not possible at all, how to get such an array?
Thanks in advance
Tobias