c# - Sorting a list with paths by deepest directory -
I need to sort a list that contains paths (relative or full), so that the deep path first appears , For example:
\ New folder \ item1 \ tools \ 1 \ new folder \ item1 \ tools \\ \ New folder \ Item1
\ new folder \ etc ..
Can I use the path class to do this?
Thank you! Jammu.
It is slightly out of the box, but you can always do this:
< Pre> var sortedList = list.OrderByDescending (p = & gt; p.Count (c => gtc; c = path.directory separator square || c == path.lldDirectorySeparatorChar);); That is how often the path separator character appears.
Comments
Post a Comment