c# - I am trying to return a True or false if a given directory contains ".exe" -


i have code return true/false;

public static bool hasexecutable(string path)     {         var exts = "*.exe";         if (path.asdirectory().exists) return true;         if( path.asdirectory().getfiles(exts).any(i => path.contains(exts))) return true;         return false;     } } 

}

my out put error stops program, missing logic here?

you can enumerate directory pattern matching , use any extension method.

public static bool hasexecutable(string path)     {         var exts = "*.exe";         return directory.enumeratefiles(path, exts).any();     } 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -