Click here to Skip to main content
15,886,774 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
var fileEntries = from f in Directory.GetFiles(Application.StartupPath + "/TrainedFaces/", "*.bmp", SearchOption.AllDirectories) let fi = new FileInfo(f) orderby fi.Name select fi.FullName;

There is some thing wrong When i put Face10,Face11 first it take face1 after it take Face10 so this is the problem

This is the output I want
[0] = "N:\FaceRecProOV - Copy (2)\FaceRecProOV\bin\Debug/TrainedFace/1\ 1.bmp"

[1] = "N:\FaceRecProOV - Copy (2)\FaceRecProOV\bin\Debug/TrainedFaces/2\ 2.bmp"

[2] = "N:\FaceRecProOV - Copy (2)\FaceRecProOV\bin\Debug/TrainedFaces/3\ 3.bmp"

[3] = "N:\FaceRecProOV - Copy (2)\FaceRecProOV\bin\Debug/TrainedFaces/4\ 4.bmp"

[4] = "N:\FaceRecProOV - Copy (2)\FaceRecProOV\bin\Debug/TrainedFaces/4\ 9.bmp"

[5] = "N:\FaceRecProOV - Copy (2)\FaceRecProOV\bin\Debug/TrainedFaces/4\ 10.bmp"

But it's give
[0] = "N:\FaceRecProOV - Copy (2)\FaceRecProOV\bin\Debug/TrainedFace/1\ 1.bmp"

[5] = "N:\FaceRecProOV - Copy (2)\FaceRecProOV\bin\Debug/TrainedFaces/4\ 10.bmp"

[1] = "N:\FaceRecProOV - Copy (2)\FaceRecProOV\bin\Debug/TrainedFaces/2\ 2.bmp"

What is wrong in the Code???
Posted
Updated 19-Sep-12 9:35am
v2
Comments
[no name] 19-Sep-12 15:27pm    
There is nothing wrong with the code. That is exactly how strings are sorted.

1 solution

You need to implement a custom sort - a string "TEXT1" is later in the default sort order than "TEXT10", "TEXT11", "TEXT1 " and so on. I would suggest the easiest way is to parse your names, and insert the leading "0" on all single digit based names. Nasty - but there is no easy way AFAIK.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900