At present i am retrieving the file names depends up on creation time of file …
private void filteringFiles()
{
string filenamepath = @"C:\defualt\Access\backupdb\";
List<String> listfiles = Directory.GetFiles(@"C:\defualt\Access\backupdb\", "backup-*.zip").ToList();
List<String> files = new List<String>();
List<String> getfiles = new List<String>();
foreach (var allfiles in listfiles)
{
files.Add(Path.GetFileName(allfiles));
//DateTime creationtime = File.GetCreationTime(files);
}
if (cbbackupforms.Text == "Month")
{
getfiles = (from string s in files where (DateTime.Now.Day - Convert.ToInt32(File.GetCreationTime(Path.Combine(filenamepath, s)).AddDays(-30).Day) < 1) && ((DateTime.Now.Year - (File.GetCreationTime(Path.Combine(filenamepath, s))).Year) == 0) select s).ToList();
}
if (cbbackupforms.Text == "ALL")
{
getfiles = files.ToList();
}
listbox1.DataSource = getfiles;
how can i list the file names depends upon creation time in ascending order ..
I mean if i created file at this time …that file will be on top of list … (ascending order depends upon file creation time)
would any one pls help on this…
Many thanks….
1 Answer