I use this piece of code to compare my two lists :
private void CompareLists(List<string> list1, List<string> list2)
{
List<string> commonList = list2.Where(g => list1.Any(x => g.Contains(x))).ToList();
}
list2 contains 15000+ items that are path to files located in my network that look like \\myserver\direcory\subdir\myfile.pdf
list1 contains items I get from an Excel sheet, for my test there are 29 items including 3 duplicates, they contain the 'myFile' part if what's in list2.
After my CompareLists function, commonList contains only 26 items, the 3 missing being the duplicates.
How can I modify my LINQ query to have those duplicates in commonList ?
EDIT : Intersect can not be used here as list1 items only contain a part of what's in list2 items.