I have 2 List objects (simplified):
var fileList = Directory.EnumerateFiles(baseSourceFolderStr, fileNameStartStr + \"*\", SearchOption.AllDirectories);
var
its even easier:
fileList.Where(item => filterList.Contains(item))
in case you want to filter not for an exact match but for a "contains" you can use this expression:
var t = fileList.Where(file => filterList.Any(folder => file.ToUpperInvariant().Contains(folder.ToUpperInvariant())));
Try the following:
var filteredFileSet = fileList.Where(item => filterList.Contains(item));
When you iterate over filteredFileSet (See LINQ Execution) it will consist of a set of IEnumberable values. This is based on the Where Operator checking to ensure that items within the fileList data set are contained within the filterList set.
As fileList is an IEnumerable set of string values, you can pass the 'item' value directly into the Contains method.
you can do that
var filteredFileList = fileList.Where(fl => filterList.Contains(fl.ToString()));