About reading file sequence

when I use [ directory.GetFiles(“D:\prod”) ] to read all the file of D:\prod .
What kind of the sequence dose thes file paths ordered in the arr[string].
I use the directory.GetFiles(“D:\prod”)(0) directory.GetFiles(“D:\prod”)(1) directory.GetFiles(“D:\prod”)(2) to log them.But It wasn’t the sequence than I see in the explor.

From the Microsoft documentation, it is clearly stated -

The order of the returned file names is not guaranteed; use the Sort method if a specific sort order is required.

If you want the files in particular order, please make use of Sort.

Karthik Byggari


Thanks but someone told me it was In order by A-Z.It was true.
But I used japanese file name. What does the japanese’s sequence.

Hi @jmy

May be it returned in the order A-Z. But we can’t assure the files will return every time in the same order.

Sorry, no idea about japanese file name sequence. As I said if you want the files in the particular order, please use Sort method.

Thanks for your help.

1 Like