Wednesday 15 April 2015

C# Sorting Directory Names using LINQ -


I found something similar, but it has been unable to work. I am very new to LINQ and therefore do not fully know that any assistance that is going on with it will be appreciated. I have directory names:

  directory-1-of-a-others article   

I want to sort them by name, but by now Kind of disabled When listing a directory they are on a network drive while staying on a RedHat server, a seemingly random mess comes in mess in the order.

Here's what I've tried:

  DirectoryInfo dirInfo = new DirectoryInfo ("Z: \\ 2013"); Var dirs = dirInfo.GetDirectories (). Orderbike (D => dirInfo.Name); Forex Currency (DirectoryInterner in Diamonds) {string month = dir.Name; Console.WriteLine (dir.Name); Var monthDirInfo = New Directory Info ("Z: \\ 2013 \\" + month); Var monthDirs = monthDirInfo.GetDirectories (). OrderBy (d => MonthError Infoc. ​​Creation Time); Forex Currency (Directory DirectoryInfo Month) {string article = monthDir.Name; Console.WriteLine (monthDir.Name); Sb.AppendLine ("  

Any help would be greatly appreciated. I am at a loss at this time. I am sure that something is clear to me, too.

You are placing your name in the root folder instead of the name of each sub-directory

then change ...

  var dirs = dirInfo.GetDirectories (). Orderbike (D => dirInfo.Name);   

to ...

  var dirs = dirInfo.EnumerateDirectories (). Orderbie (D => D. Knom);   

and

  var monthDirs = monthDirInfo.GetDirectories (). Orderbie (d => month display; season time);   

to ... var monthDirs = monthDirInfo.EnumerateDirectories () .orderbie (d = & gt; d.CreationTime);

I used it because it is more efficient before they start ordering them, first all directories will be collected.

No comments:

Post a Comment