I have the following code:
foreach (string file in FleName)
if (!ActualFiles.Any(x => Path.GetFileName(x).Equals(file)))
{
IList<string> MissingFiles = file;
}
I have 3 if statements that access this method. At the end of the if statements I need to show the entire IList.
So heres what I want. First if statment goes into the method and returns every file with the word “EqpFle -” before each value
The second if statemenet I want it to return all those items with “DPFle-” in front of all the names, and simialr for the third.
At the end of all the if statements (this is in a for each) I want it to read the entire list.
how owuld I do this?
the ifs basically look as follows:
foreach (string file in files)
{
if
{
Check <----thats the method
}
if
{
Check <----thats the method
}
if
{
Check <----thats the method
}
}
It’s not entirely clear exactly what’s going on here – but basically if you create an empty list to start with and pass it into the method as an argument, the method can add the new entries to it.
This would almost certainly be simpler with LINQ (probably using
Concat, and a method which returned anIEnumerable<string>of files matching a given pattern), but it’s not entirely obvious what you’re trying to do, which makes it hard to suggest a LINQ approach.