I found something similar here , but couldn't get it to work. I am very new to LINQ and therefore not quite sure what is happening to him. Any help would be greatly appreciated. I have directory names, for example:
directory-1 article-about-something-else
I want to sort them by name, but so far have failed. They are located on a network drive located on the RedHat server. The directory listing goes into a distorted mess in seemingly random order.
Here is what I tried:
DirectoryInfo dirInfo = new DirectoryInfo("Z:\\2013"); var dirs = dirInfo.GetDirectories().OrderBy(d => dirInfo.Name); foreach (DirectoryInfo dir in dirs) { string month = dir.Name; Console.WriteLine(dir.Name); var monthDirInfo = new DirectoryInfo("Z:\\2013\\" + month); var monthDirs = monthDirInfo.GetDirectories().OrderBy(d => monthDirInfo.CreationTime); foreach (DirectoryInfo monthDir in monthDirs) { string article = monthDir.Name; Console.WriteLine(monthDir.Name); sb.AppendLine("<li><a href=\"/2013/" + month + "/" + article + "\">" + TextMethods.GetTitleByUrl("2013/" + month + "/" + article) + "</a></li>"); } }
Any help would be greatly appreciated. At the moment, I'm a little confused. I am sure that I also have something obvious.
source share