I’m a little confussed as to whether or not this is the best method to retrieve what I need. I’ve got a list of files I’ve gotten from a directory using ftp. I need to filter the list of file names depending on the file mask entered by the user into a List<string>. I love LINQ, but not having used it for a few months I seem to have lost some of my skills already. I’ve come up with the following so far. I would be greatful if someone could verify what I’ve done is the best approach.
foreach (string s in fileMasks)
{
fileNames.AddRange(
directory.Files.ToList().Where(a => a.Name.EndsWith(s))
.Select(b => b.Name)
);
}
you could just simplify your query