winforms - Is there any better way to check for existance of several sub directories in C# than using nested ifs? -
i trying check if needed sub directories exists , use snippet of code :
directoryinfo gccdir = new directoryinfo(txtgccpath.text); list<string> subdirectories = new list<string>(); foreach (var item in gccdir.getdirectories()) { subdirectories.add(item.name); } if (subdirectories.contains("bin") && subdirectories.contains("i686-w64-mingw32") && subdirectories.contains("include") && subdirectories.contains("lib") && subdirectories.contains("libexec") && subdirectories.contains("share")) { //statements }
is there better way doing this?
in situations there need verify multiple conditions, whats best way avoid excessive usage of if else statements?
you like
if(new[] {"bin", "include", "lib"}.all(subdirectories.contains)) { }
etc.
Comments
Post a Comment