Find out Latest Folder Name

Posted by Venkatesh under C# on 6/1/2011 | Points: 10 | Views : 4346 | Status : [Member] | Replies : 1
Hi,

In a folder having sub folders are there.These sub folders are created when user clicks on button and Folder Names are dynamically generating.

My problem is how to find out latest folder name?

Thanks
Venkatesh.P




Responses

Posted by: Ndebata on: 6/1/2011 [Member] Starter | Points: 25

Up
0
Down
Hi
DirectoryInfo dinfo = new DirectoryInfo("<Folder Path>");

DirectoryInfo latestdir = dinfo.GetDirectories().OrderByDescending(f => f.CreationTime).FirstOrDefault();
if (latestdir != null)
{
//latestdir is the Directory created last
//latestdir.FullName
}


Thanks,
Debata

Venkatesh, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response