bool match = Regex.IsMatch(Path.GetFileName(Directory.GetFiles(string.Format(@"C:\apps\{0}\", app), "*.config").ToString()).ToLower(), "loggingconfiguration.config");
I have been using the code below to place the configs into a list and then looping through each of them to see if they match the filename of "loggingconfiguration.config"
or "*app*.config."
This works without a problem, but I am not sure if this is the best way to handle the scenario.
List<string> configFiles = Directory.GetFiles(string.Format(@"C:\apps\{0}\", app), "*.config").ToList<string>();
foreach (var item in configFiles)
{
if (item.ToLower().Contains("loggingconfiguration.config") || (Path.GetFileName(item.ToLower()).Contains(app)))
{
//Do something
}
}
I wanted to know if there is a way to cut out the step of looping through the list by searching for the "loggingconfiguration.config"
or "\*app*.config"
first. My attempt at the top results in system.string[] for the `Path.GetFileName(Directory.GetFiles(string.Format(@"C:\apps{0}\", app), "*.config") search.