FolderItem slow to create

Hi all,

This line of code

Var theFile As New FolderItem(myLocalPath, FolderItem.PathModes.Shell)

Is so slow - it’s part for a file search app that calls this for each file it’s found, so often, quite a lot of looping going on - profiling code shows this is the culprit and remming it out makes execution times almost instant inside the loop.

Is there an alternative?

Regards, Dave.

Why do you use Shell as mode and not native?

I’ve tried both actually Christian, same timings sadly :frowning:

Tell use more.

Is it macOS, MS-Windows or Linux?

Is the file on a local disk or network sahre?

It’s on a Mac Kevin - latest verz of Xojo. Files on local and smb share same - obviously quicker when files are local! Reverting to using shells to get what I need in this instance - taking the long way around - production pressure etc!

OK.

FolderItems seem to have quite a bit of overhead. I would delay having to create the FolderItem until absolutely necessary.

If this was MS-Windows you could have possibly stayed with file paths and used Declares to call the Win32 file APIs directly.

If you have the MBS plugins you could always try NSURLMBS to see if that is any faster.

1 Like

I shall investigate Kevin as I do use Christian’s plug-ins… thanks

1 Like

FolderItems have always been slow to create. MBS has a platform-abstract plugin for listing files quickly FileListMBS

2 Likes

Thanks Tim, I’ll take a look.

FileListMBS IS faster for looping over folderitems. But the creation of folderitems still is the limiting factor.

Can you provide timings ?

Why?
What do you do with the folderitems once you have them?
Get properties?
Change names?
read icons?

If it is ‘get something’, then there may be a way to get that info from the OS using a shell and parsing text.

You might also try the Chilkat plugin, the FileAccess Class is one that doesn’t need a paid license to use.

Specifically DirCreate and DirAutoCreate. DirAutoCreate is one of my favorites because it will recursively create folders to ensure your path exists. So if you need C:\Temp\Test123\NewFolder and C:\Temp doesn’t exist, it will create all three nested folders.

1 Like

FolderItem: 31,712 files in 58 ticks.
MBS: 31,712 files in 34 ticks.

Timing courtesy the MBS sample project, I didn’t choose ticks :upside_down_face:

Shelling is the route I’ve taken Jeff… getting what I need at respectable speeds for now.