Can we recognize which file is executable (i.e. chmod +x
) using Mono under Linux? Is there any method in common .Net/Mono base class libraries?
Edit: native Linux executables
Can we recognize which file is executable (i.e. chmod +x
) using Mono under Linux? Is there any method in common .Net/Mono base class libraries?
Edit: native Linux executables
Though it's not exactly a method to find .NET executables, you can load the assembly with Assembly.Load
. If it fails, it's not a .NET assembly.
Yes, we can, but I don't know of a common .NET class that does it. You could look at the mono sources. :)
Edit:
The original link refers to a helper application, which can't be found. However, the Mono Project page has something to say about binfmt support too, and no helper app seems to be required.
The best you can do is use the Mono.Unix.Native
namespace to check file permissions, I believe. You can check whether a file has executable permissions (for owner/group/others) by calling the Syscall.Stat
method. More specifically, you'll want to look into the FilePermissions
enum.