var directory = new DirectoryInfo("C:\example");
string pattern = "LOG" + "_" + "NA" + "_" + "3465";
var validFiles = directory.GetFiles("*.xml");
List<string> list = new List<string>();
foreach (var item in validFiles)
{
string a = item.ToString();
if (a.Contains(pattern))
{
list.Add(a);
}
}
I wanted to get the latest file with the above pattern from the directory specified. I had tried the as above to get the file that as the common pattern, but, I am stuck in getting the latest file among the files in <list>
. Your help is very much appreciated.