[Mono-list] how to do chmod in C# program?

Miguel de Icaza miguel@ximian.com
Mon, 19 Apr 2004 16:45:45 -0400


Hello!


> my program does this:  
>  
> FileStream file = new FileStream(blah-blah-blah);
> file.Write(byteData, 0, byteData.Length);
>  
> The resulting file is always created with mode 100600 (owner: read,
> write, others: nothing).
>  
> Is there any way to change the mode of this file to 100604 (to let
> others read the file) within my C# application?

You can use Mono.Posix:

	using Mono.Posix;

	...
		Syscall.chmod ("file", (FileMode) hex_value);

Notice that you should use an hex-value with the current release of
Mono, as we shipped with wrong FileMode values.