[Solved] How to count the amount of files in a directory

Hello, I’m working on a thing that needs to figure out the amount of files in a directory to make sure that the new files actually save, though I can’t seem to figure out how to get it to count the amount of files. The “Read Directory” action doesn’t seem to work for some reason. All of the files are titled 1.txt, 2.txt, etc.

Any help is greatly appreciated!

Hi @Cheezman64!

I have not a solution in mind but i have an idea which is in the form of question in fact:
Is it possible that, with GDevelop, we can ask the filesystem for by example, to have the number of files in a precise repertory?

Xierra

Are you using it correctly? I have this event:

image

on this array:



and in the debugger when I run it, I get:

1 Like

Ah, no I wasn’t. I thought that “stores them in an array” meant adds the results as children to the array.

Is there any way I could store this result as a variable?

An array is a variable. Do you mean in a string?

yes, sorry for the mistake

I would repeat for each child in the array, and append the value of the child to a string variable (maybe with a separator like a comma).

I managed to get it to work, thank you!

I can’t edit the title for some reason, but this is solved

1 Like