How to Sort and get the files in Oder

new DirectoryInfo(YourDir).GetFiles().OrderBy(Function (x) x.Name).Select(Function (x) x.FullName).toArray

But check its failling on lexically ordering
grafik

if we can rely on this page number token pattern we can do:

(From fi In New DirectoryInfo("C:\_demo\DemoOrder").GetFiles()
Let pns = Regex.Match(fi.Name,"(?<=page)\d+").toString
Order By CInt(pns)
Select f=fi.FullName).toArray

if its coming from a splitting job, then maybe a sort on creation time can help

new DirectoryInfo(YourDir).GetFiles().OrderBy(Function (x) x.CreationTime).Select(Function (x) x.FullName).toArray

2 Likes