How to check if file is executable in c#?

I’m stuck on Stage #mg5.

I’ve tried ..Searching everywhere, but can’t find a command that checks if a file is has executable permissions

And here’s a snippet of my code:

string PATH = Environment.GetEnvironmentVariable("PATH");
IEnumerable<string> folders = PATH.Split(Path.PathSeparator);

foreach (string folderPath in folders)
{
   DirectoryInfo directory = new DirectoryInfo(folderPath);
    try
    {
        var files = directory.GetFiles("");
        foreach (var file in files)
        {
            // How to check if a file is executable?
        }

    }
    catch (DirectoryNotFoundException ex)
    {
        // Do nothing
    }

Hey @vadimuha, here are a couple of helpful references you can check out:

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.