Read contents of directory

Is there a fast way to parse the contents of a directory using Xojo? In VB Net I can get all files from a folder and half a dozen sub folders (over a 1,000 files) almost instantly. Doing the same thing with Xojo using the practices recommended here it takes so long Xojo becomes unresponsive.

Any suggestions? Or is this a quirk of Xojo?

If you want more speed than FolderItem class in old/new framework, you can try MBS Plugins with FileListMBS class:

http://www.monkeybreadsoftware.net/class-filelistmbs.shtml

We achieve high speed by not using folderitems.

I see it as SPAM because there is no disclaimer who is writing such a “BUY IT” reply.

Who needs to a plugin anyway?
See Fastest File Finding… where Andrew Lambert posted a link to the old forum.

There is a quick solution using WinAPI calls.

It is not.

Ok the declares are what I was looking for, as this is windows specific. Thanks Thomas.

I’m a little green with declares. How can I modify the ListDir from the link to do the folling:

  1. Recurse through all subfolders and include all files from sub folders.
  2. Return the full (native) path, instead of only the file name.

Thanks again.

  1. Return the full (native) path, instead of only the file name.
    http://documentation.xojo.com/index.php/FolderItem

Use .NativePath instead of .DisplayName (or Name)

[quote=320931:@Emile Schwarz]
Use .NativePath instead of .DisplayName (or Name)[/quote]

I know how to use folderitems. I’m talking about declares.

Can anyone show me how to get the GetFullPathName declare to work?
https://msdn.microsoft.com/en-us/library/windows/desktop/aa364963(v=vs.85).aspx

DWORD WINAPI GetFullPathName( _In_ LPCTSTR lpFileName, _In_ DWORD nBufferLength, _Out_ LPTSTR lpBuffer, _Out_ LPTSTR *lpFilePart );
Translates roughly to

declare GetFullPathName lib "??" alias "GetFullPathNameW" (name as CString, bufLen as Integer, bufPtr as Ptr, filePartPtr as Ptr) as Integer

Don’t know the lib name, but it’s the same as for the others, probably.

You’d then call it like this:

dim buf as new MemoryBlock (1024) dim nameLen as Integer = GetFullPathName (f.NativePath.ConvertEncoding(Encodings.UTF8), buf.Size, buf, nil) dim fullPath as String = buf.CString(0).DefineEncoding(Encodings.UTF8)

Sirry, NAP collateral effect.

Since you know the path you started with, you can build the path as you recurse the folders. It’s what I do.

It looks like it will take some more fooling around. Thanks for your help.

[quote=320889:@Thomas Eckert]I see it as SPAM because there is no disclaimer who is writing such a “BUY IT” reply.

Who needs to a plugin anyway?[/quote]

Lots of people have it and don’t know what it can do, so its worth pointing out.

I guess it boils down to how much you value your time.

2.5 hours (if you know what you’re doing) of R&D, coding and testing VS buying a plugin for £50.

If your time is worth £25/h or less, then code it yourself :slight_smile:

If you’re writing it for a client, pass on the cost then you can reuse the plugin over and over as well as it having other functionality you might use.

Then factor in writing it for the mac if you need cross platform in the future and you can see that plugins really are value for money.

I think, in part, what Thomas is pointing out is, that besides “hey use the plugin”, there’s no attempt to answer the question at hand in any other way like pointing out that there are other alternatives (iterating folderitems, declares, etc)

It might as well just be an advertisement on the forum pages saying “Buy the MBS plugins.”

Correct me if I missed the mark @Thomas Eckert

Yeah I can see that point of view too, but as Christians plugins do encompass an awful lot, its easy to miss something even if you have it (as I do) :slight_smile: I don’t think a lack of attempting to answer the problem is a mute point, after all, neither have we :wink: The more bumps, the more someone might chime in with an answer :slight_smile:

PS. More :slight_smile: :slight_smile: :slight_smile: I didn’t use enough (I need sleep)

Note I didn’t say they do not encompass a lot of functionality
Just that we do get complaints about non-answers that just plug MBS without really addressing the question beyond saying “hey if you used my plugins …”

This has been true since way before these forums existed & I’m sure one could scour the old NUG mailing lists & old forums for exactly the same kinds of complaints

Like you I’m just saying that I can see Thomas point of view

IMHO, Peeps need to lighten up :slight_smile: Xojo would be worse off without MBS, soooo much missing functionality :wink:

If I wrote a plugin, my next app would be one to monitor the forums and autopost replys when someone mentioned keywords about something it could :wink:

Ooo, maybe Christian has one (where’s that shifty eyes emoji)

PS. Sorry for polluting this thread

I agree somewhere with Norman on this - at least in general terms. A reply that suggests to use the MBS plugins should at least indicate an example or reference to one, or some pointers which functions to use. The MBS plugin functionality is huge and even I have sometimes trouble finding something I know that must be in there. I usually then email Christian or chat to him via his Website, but I have the advantage of being in the same time zone, so he’s usually quick at responding. People in the U.S. may not get a quick response, hence a bit more detail here would be fair to expect.

In this case, though, Christian has pointed out the documentation of the relevent class, so the reader only needs to read over the few dozen functions to find the ones that would help. In this particular case, even just using the FileListMBS class will speed up things automagically.

[quote=321282:@Norman Palardy]I think, in part, what Thomas is pointing out is, that besides “hey use the plugin”, there’s no attempt to answer the question at hand in any other way like pointing out that there are other alternatives (iterating folderitems, declares, etc)

It might as well just be an advertisement on the forum pages saying “Buy the MBS plugins.”

Correct me if I missed the mark @Thomas Eckert[/quote]

Excatly. And in case there is such an advertisement there should be at least a disclaimer.

Well, how much does Christian really need to advertise that his plugins are not free?

I’d assume that everyone knows about MBS plugins already, and that they’re not free. And if they don’t, well, then it’s good Christian points that out for those who need a solution.

This is a fairly small community, and unless someone can accuse Christian of false advertising or some other kind of fraudulent behavior, I don’t think this needs to be made into a problem.

@Thomas: the feature to ignore post from specific persons is already there. You have to open the profile of the user. Then it’s contols/Ignore member.