Getting array of folder names in a directory very slow

I have a Xojo program that gets all of the folder names in a specific directory on our company LAN, then lists them in a ComboBox. It is very slow, and takes about 20 seconds to come up with the list. There are about a 130 folders in directory. LAN speeds to that directory are plenty fast, and outputting the names to a text file from scripting is super fast. Is there a more effecient way for me to code this using Xojo?

Here’s the code.

Dim BASE_PATH as string ="\\SERVERNAME\source$\software\WORKSTATION\"

dim VP as FolderItem
VP = GetFolderItem(BASE_PATH)

dim VPArray () as string

Dim VP2 As FolderItem
If VP <> Nil And VP.Directory Then
  Dim items As Integer = VP.Count
  For i As Integer = 1 To items
    VP2 = VP.Item(i)
    If VP2.Directory Then
End If


Xojo’s file recursion is notoriously slow in this regard (at least on Windows). Most folks use declares or MBS for this.

Take a look at this relatively recent thread:

Not able to makes head nor tails out of that example.

Take a look at this post. It’s nested in a link or two.

No help. Riddled with errors. Doesn’t like Funtion/End Function

You remove those lines. You need to make a method that matches the Function definition line in the IDE, then paste in the code from the between Function…End Function.

I did that too, of course. That’s where is gets really riddled with errors.

I put together an example project for you, modified from this post:

Thanks. I was able to modify that with my LAN share. Unfortunately, it isn’t any faster than my current code.

Unfortunately that’s as much as I can help with this. Hopefully someone will join the discussion that has a fast routine for file iteration on Windows.

Thank you for helping!

1 Like

Wound up just using PowerShell to get the info. Went from taking 35 seconds to under 2 seconds.