I have a List<string> and a FileInfo[]. I need to know if the entire contents of the FileInfo[] are in the List<string>. What is the most LINQy and error-free way to do that?
I was doing this, based on responses here, it returns false however, I expected it to return true:
// I want to know if all of these files are in the directory
List<string> allFilesWanted = new List<string>();
allFilesWanted.Add( "a1.txt" );
allFilesWanted.Add( "a2.txt" );
// Simulate a list of files obtained from the directory
FileInfo[] someFiles = new FileInfo[3];
someFiles[0] = new FileInfo("a1.txt");
someFiles[1] = new FileInfo( "a2.txt" );
someFiles[2] = new FileInfo( "notinlist.txt" );
// This returns "false" when I would expect it to return "true"
bool all = someFiles.All( fi => allFilesWanted.Contains<string>( fi.Name ) );
Thanks.