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
Post a Comment