[Mono-devel-list] File permissions in C#

Garthfield Carter garth at webconexion.net
Sat Aug 28 11:41:26 EDT 2004


Hello,

I'm trying to work out how to change the permissions of a file in a C# ASP.NET page. I've read through cover to cover "Mono - A Kick Start" and the file sections talk about how to create a file but not how to change the permissions afterwards.

Basically I use FileInfo to check whether a file exists, if it doesn't I create it:

FileInfo fileData = new FileInfo( "test.txt" );
if(fileData.Exists == false)
{
    fileData.Create();
}

This works perfectly, however the permissions on the file as this is run via ASP.NET using Mod Mono are:

drwxrwxrwx    2 webstall webstall     4096 Aug 28 16:29 .
drwxr-xr-x    4 webstall webstall     4096 Aug 28 13:05 ..
-rw-------    1 apache   apache          0 Aug 28 16:29 test.txt

Because Mod Mono runs as the apache user and group it's created the file accordingly, not a massive problem. I would just like to set the permissions to 666 so that the files can be manipulated by the user of the directory to enter contents afterwards.

How can file permissions be set in C# using Mono? I can't seem to find any way of executing a system call, if I could I would run the chmod command.

Garthfield
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20040828/1490bd52/attachment.html 


More information about the Mono-devel-list mailing list