I have this code:
var neededFiles = new[]{ "file1.exe", "file2.exe", "file3.exe", "file4.exe" };
IEnumerable<string> notFound = neededFiles.Where(f => !File.Exists(f));
if (notFound.Any())
{
MessageBox.Show(string.Format(notFound.Count() > 1 ?
"App cannot find these files - {0}" :
"App cannot find this file - {0}",
String.Join(", ", neededFiles)), "Test", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
It work's OK, but If I have for example file1.exe, file2.exe, file3.exe files code anyway prints "App cannot find these files - file1.exe, file2.exe, file3.exe, file4.exe". How to make it print only needed file which not exists? Example: if exists file1.exe, file3.exe, it must print: App cannot find these files - file2.exe, file4.exe Thanks in advance
FIXED: The best overloaded method match for 'string.Join(string, string[])' has some invalid arguments This helped me.