>>Hi All,
>>
>>I am looking for the quickest way to get the name of the oldes file of a specific pattern in a given directory. I can loop through the results of Directory.GetFiles() but wondering if there is a more efficient way.
>>Thanks
>>Tim
>
>Why not just use adir() and then sort the array by the file date column?
Thanks Tracy,
After a little testing it appears this code always returns the files as earliest first. I am thinking I could just use the first file for what I am doing.
string filter = "Spot_*.xml";
string path = AppDesktop.QueueDataPath;
this.txtFileList.Text = "Files in Directory: ";
DirectoryInfo directory = new DirectoryInfo(path);
FileInfo[] files = directory.GetFiles(filter);
foreach (FileInfo fi in files)
{
this.txtFileList.Text += "\r\n";
this.txtFileList.Text += fi.Name + " - " + fi.LastWriteTime;
}
Timothy Bryan