I need much the same thing…but specifically for Mac OS – so Windows Declares won 't cut it – I would just recurse through folder items…but I will be collecting way over a million file paths…so I was looking for a speedy route. I do have Christian’s MBS Plugin…and I briefly looked at that before I slept on the problem. Then I thought…hey…how about I just shell out and run something like “ls -d -1 $PWD/**/*” and collect the result (probably in a file I could open and read through PDQ…but perhaps it could all be done in memory).
I’m surprised no one ran into this before…if the file attributes returned include a set bit other than the Directory bit, the directory test fails and it won’t go down that directory. The test needs to change to look at just the Directory bit, like this:
If FindHandle > 0 Then
Do
if (result.int32value(0) And 16) = 16 Then
'if this is a directory then resurse through the directory to get all files
I ran into the issue when I tried this on a OneDrive directory. The FILE_ATTRIBUTE_REPARSE_POINT bit was set as well.
That is super cool, thanks Neil , Is there a way to have same thing for Mac as well, no idea why but folder item seems super slow and with each XOJO release the customers complain that the app is more and more slow so I guess I’ll have to look on other optimizations on this part .
For other reasons, I fill an array with FolderItems (a directory contents), then I use that array to load small images and apply to cloned Canvas in a Window.
Works nicely (vs skip some Canvas Clone without image) and fast (but tested on only < 20 images).
As I was looking for getting all filenames from a directory I stumbled over this forum chat. I was wondering why so much code is needed for such a “simple” task. I then found this in documentation. The key is to iterate through the children:
Var desktopFolder As FolderItem = SpecialFolder.Desktop
For Each file As Folderitem In DesktopFolder.Children
If file <> Nil Then
ListBox1.AddRow(file.Name)
End If
Next
This sample can easily adapted for someones needs.
The issue wasn’t how to iterate through the children, it was how to do it quickly. Folderitem methods are notoriously slow. Also the Children function did not exist at the time of the discussion. I do not know how it performs in comparison.
Agree and can imagine it didn’t exist at that time. The point is I was googling several times and always landed here. So I thought that any other person may have the same problem may find a solution here.