Quantcast
Channel: order by in lambda expressions - Stack Overflow
Viewing all articles
Browse latest Browse all 2

order by in lambda expressions

$
0
0

I'm trying to sort the data in lambda expression in the following case.

if (Directory.Exists(Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["ErrorLogPath"].ToString()))){    string path = Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["ErrorLogPath"].ToString());    // a.Select(p => Path.GetFileNameWithoutExtension(p));    var a = Directory.GetFiles(path);    if (a != null)    {        Session["gvData"] = a.ToList();        BindDataToGrid();    }}

In vara i get list of complete path of files like

c:\\logfiles\\01022012.txt. 

How can I get vara sorted on basis of 01022012I tried

var a = Directory.GetFiles(path).OrderBy(p=>Path.GetFileNameWithoutExtension(p));

but not working. Is there any thing am I doing wrong?

Getting result as

"C:\\LogFiles\\01112012.txt""C:\\LogFiles\\08102012.txt""C:\\LogFiles\\14092012.txt""C:\\LogFiles\\15102012.txt""C:\\LogFiles\\17102012.txt""C:\\LogFiles\\19092012.txt"

Expected is

"C:\\LogFiles\\14092012.txt""C:\\LogFiles\\19092012.txt""C:\\LogFiles\\08102012.txt""C:\\LogFiles\\15102012.txt""C:\\LogFiles\\17102012.txt""C:\\LogFiles\\01112012.txt"

Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles



Latest Images