Hi
I have a folder which contains text files . Guide me in sorting the files according to date and time.
Kritika
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Iftikar HussainPosted Aug 12, 2013, 2:43 AM
var files = dinfo.GetFiles("*.*").OrderByDescending(s => s.LastWriteTime).ToList();
Iftikar
kritika RanaPosted Aug 12, 2013, 3:46 AM
Now I want the text of some files are to be written on MS outlook express. How to write the code for it in C#
Kritika
Iftikar HussainPosted Aug 12, 2013, 3:28 AM
Regards,
Iftikar
kritika RanaPosted Aug 12, 2013, 3:10 AM
Thanks for the guidance . The code you send is working now.
kritika
kritika RanaPosted Aug 12, 2013, 2:34 AM
My code looks like:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string path = "D:\\Test";
DirectoryInfo dinfo = new DirectoryInfo(path);
var files = dinfo.GetFiles("*.*").OrderByDescending(s => s.LastWriteTime).ToList();
}
}
Its not showing anything and also files remain unsorted
kritika
Iftikar HussainPosted Aug 12, 2013, 2:32 AM
Regards,
Iftikar
kritika RanaPosted Aug 12, 2013, 2:29 AM
The code send by you is not working.
Kritika
Sanjeeb LenkaPosted Aug 12, 2013, 2:13 AM
using System.IO;kritika RanaPosted Aug 12, 2013, 2:08 AM
What will be the namespace for DirectoryInfo
Iftikar HussainPosted Aug 12, 2013, 1:52 AM
You can do by using lambda expression like this
Regards,
Iftikar
Sanjeeb LenkaPosted Aug 12, 2013, 1:47 AM
http://stackoverflow.com/questions/9001544/sorting-a-listfileinfo-by-creation-date-c-sharp
http://stackoverflow.com/questions/5049202/sorting-files-by-date