Reputation: 3160
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
Upvotes: 1
Views: 1215
Reputation: 147240
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.
Upvotes: 4
Reputation: 32037
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.
Upvotes: 1
Reputation: 23759
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.
Upvotes: 0