This would be one way to do it, there would be countless of other ways.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
List<string> filenamesFromDatabase = new List<string>();
List<string> filenamesFromDirectory = new List<string>();
filenamesFromDatabase.Add("firstfile.txt");
filenamesFromDirectory.Add("firstfile.txt");
filenamesFromDirectory.Add("anotherfile.txt");
foreach (string filename in filenamesFromDirectory)
{
if (filenamesFromDatabase.Any(s => filename.Contains(s)))
{
Console.WriteLine(filename);
}
}
Console.ReadLine();
}
}
}
Output: firstfile.txt