Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set the executable file attribute in .net

Tags:

.net

How do I make a file executable from within a .net program running under Linux/Cygwin please? I really hope there is a better answer than "execute chmod". Many thanks.

like image 925
Joe Huha Avatar asked Jun 05 '26 12:06

Joe Huha


2 Answers

you can use chmod from mono.

   Mono.Unix.Native.Syscall.chmod (string path, FilePermissions mode)

http://docs.go-mono.com/index.aspx?link=M%3AMono.Unix.Native.Syscall.chmod

like image 81
Blau Avatar answered Jun 08 '26 03:06

Blau


Since .NET 7, the method System.IO.File.SetUnixFileMode allows you to set the Unix file mode of a path. You wouldn't need to call out to chmod, resulting reduced consumption of resources.

like image 36
John Källén Avatar answered Jun 08 '26 01:06

John Källén



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!