foreach - C# bool file name -


i have code:

bool containsnonallowedcleofiles = directory.enumeratefiles().any(file => !allowedcleofiles.contains(file.name));  if (containsnonallowedcleofiles == true) {     //how can print file names foreach? example     foreach ()     {         messagebox.show(string.join(", ", unallowedcleofiles))); //print after comma unallowed files, how to?     } } 

it must print "containsnonallowedcleofiles" files name.

thanks

you not need loop.

you have use where() filter files:

var nonallowedcleofiles = directory.enumeratefiles()                                    .where(file => !allowedcleofiles.contains(file.name)); 

and check if record found show file names delimited comma :

if(nonallowedcleofiles.any())     messagebox.show(string.join(", ", nonallowedcleofiles.select(x=>x.name))); 

Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

Nuget pack csproj using nuspec -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -