I am having some trouble searching directories for Files that have certain criteria in their file names. Below is my code and it captures the correct Files most of the time but sometimes skips the files it needs to capture. What is the best way to do this?
Many thanks.
So below I'm trying to capture All Files in a Directory that have the word "FINAL" and the correct Actual_Date. I have a datatable called dtResult2 that has these Actual_Dates stored in them.
foreach (DataRow drow in dtResult2.Rows)
{
//check for Null and start searching if not Null
if(drow["Well_Name"] != DBNull.Value)
{
//Now lets start searching the entire ARCHIVE folder/subfolders for a DWG that has
//this Well_Name and Actual_Date with FINAL in File Name...
DirectoryInfo myDir = new DirectoryInfo(myCollection3[v]);
//Collect the Final, Approved DWGs only...
var files = myDir.GetFileSystemInfos().Where(f => f.Name.Contains("FINAL") || f.Name.Contains(drow["Well_Name"].ToString()) || f.Name.Contains(drow["Actual_Date"].ToString()));
//More code not shown due to premise of question..
}
}