LINQ Query for file handling

Ddd
Posted by Ddd under LINQ category on | Points: 40 | Views : 2832
//This query will display the names of files in c drive ,their count and arrange them in order of their

//creation dates
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace ConsoleApplicationlinq
{
class Program
{
static void Main(string[] args)
{
string p = "c:\\";
DirectoryInfo d = new DirectoryInfo(p);
var z = d.GetFiles().Count();
Console.WriteLine("total number of files" + "---" + z);
Console.WriteLine("---details----");

FileInfo[] k = d.GetFiles().OrderBy(w => w.CreationTime).ToArray();
foreach (var x in k)
{
Console.WriteLine(x.Name + "---" + "creation time with date" + "----" + x.CreationTime);


}
}


}
}

Comments or Responses

Login to post response