How to get file names in a folder without using for each loop

hi I am trying to get file names without using for each loop. I already know how to get it with the for each loop. but can someone help me get the file names using a while loop as my whole workflow depends on a while loop. using a for each loop inside my while loop does not get the right results.
Spear Internal Mark 1.0.xaml (39.1 KB)

HI @Shazid_Rahman

Assign a String of array var “Demo”-> Directory.getFiles(“Your folder path”,“Filename*.Extension”)

Now assigna int variable “Counter” = 0

In while loop give the condion Counter <= Demo.Count
- increment the counter for every iteration.

Hope this helps

Regards
Gokul

can you edit my workflow to match what you said i am having trouble.

HI @Shazid_Rahman

The file extension will be?

Regards
Gokul

HI @Shazid_Rahman

Here is the updated workflow check on this hope it will work.

Spear Internal Mark 1.0.xaml (38.9 KB)

In the FIlepath assign give your extension after the “,”

Regards
Gokul

Hi @Shazid_Rahman,

Try the solution provided by @Gokul001 , which should work and mark solution if it does or else let us know to provide some more solutions.

Thanks