How to determine if a file is executable?

前端 未结 6 1385
温柔的废话
温柔的废话 2020-12-21 01:36

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 poss

6条回答
  •  心在旅途
    2020-12-21 02:01

    You should be able to pretty much start with step 5. Ie check the file extension first. Windows lives for file extensions. There's not much you can do without them.

    If you recognise the extension as an executable, then you can pass it to Process.Start or open the file and find out which executable you should be passing it to. I would also look for the .net equivalent to ShellExecute, because I'm not 100% convinced it's Process.Start. (I've not really done much .net/c# coding in the last 5 years though, so I could be wrong here.)

提交回复
热议问题