How to determine if a file is executable?
<p>I'm writing a program that (part of what is does is) executes other programs. I want to to be able to run as many types of programs (written in different languages) as possible using <code>Process.Start</code> . So, I'm thinking I should:</p>

<ol>
<li>Open the file</li>
<li>Read in the first line</li>
<li>Check if it starts with <code>#!</code></li>
<li>If so, use what follows the <code>#!</code> as the program to execute, and pass in the filename as an argument instead</li>
<li>If no <code>#!</code> is found, check the file extension against a dictionary of known programs (e.g., <code>.py -&gt; python</code>) and execute that program instead</li>
<li>Otherwise, just try executing the file and catch any errors</li>
</ol>

<p>But, I'm thinking it might be easier/more efficient to actually check if the file is executable first and if so, jump to 6. Is there a way to do this?</p>
