Removing/Adding items from/to a folder - Help please

Hello,

I asked this question a few years ago and was given a solution that worked, but I forgot how it is done, something like to OS needs to be refreshed, I can’t remember.

OK I have a folder and I use this…

For i = myFolder count down to 1
do something
next i

so now I add a file to that folder, and I use the same code again via a pushbutton…
For i = myFolder count down to 1
do something
next i

this time that file is not recognised, but if I click that pushbutton again the file is recognised.

How can I fix that so the clicking the pushbutton the first time recognises the just added file?

Thanks.

Lennox

Do you refresh the folderitem that is pointing to that folder each time before going through the loop? I am not sure that it will automatically see additions or deletions made within the folder if you don’t.

Thanks Harrie,

I am not sure, (don’t understand), what you mean by “Do you refresh the folderitem that is pointing to that folder each time before going through the loop?”

Could you explain how to do that?

Thanks.

Lennox

You have code somewhere that you used to obtain a folderitem pointing to that array. Go through that code, put it in a method if needed, and go through that code before you go through the loop to process the contents in the folder.

Yes Harrie,
As I remembered it that was the solution, but I don’t know how to implement it, could you post some code?
Is it something to do with redim?
Thanks.
Lennox

Thanks Harrie,
I got it, as you recommended.
Thanks again.
Lennox