Looping through file name in folder

image0
image1
image2
image3
image4
image5
image6
image7
image8
image9
image10
image11
image12
image13
I used directory.getfiles(FolderPath) getting output
image0
image1
image10
image11
image12
image13
image2
image3
image4
image5
image6
image7
image8
image9

I need to get correct order
Thanks in advanced @yochi

@srujana13a5,

Follow these two steps.

Thanks,
Ashok :slight_smile:

Hi @srujana13a5

Try the below syntax:

pdfFiles = Directory.GetFiles("YourPdfDirectory").OrderBy(Function(pdf) pdf).ToArray()

The above syntax will take the files in a order.

Hope it helps!!

we would recommend to be more specific on the samples (as we expect also the paths)

arrOrderedFullPaths | String Array =

(From fi in new DirectoryInfo("YourFolderPath").GetFiles()
Let nas = System.Text.RegularExpressions.Regex.Match(fi.Name, \d+).Value
Let nai = CInt(nas)
Order By nai
Select f = fi.FullName).ToArray
1 Like