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

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -