Question : Setting folder and file permissions in C#

I need a way to set folder and file permissions through C# and XCACLS.VBS is not working.

Answer : Setting folder and file permissions in C#

DirectoryInfo dirInfo = new DirectoryInfo(@"C:\Temp");

// Get a DirectorySecurity object that represents the current security settings.
DirectorySecurity dSecurity = dirInfo.GetAccessControl();

// Add the FileSystemAccessRule to the security settings.
dSecurity.AddAccessRule(new FileSystemAccessRule(@"Administrator\vinod",
FileSystemRights.Delete,
AccessControlType.Deny));

// Set the new access settings.
dirInfo.SetAccessControl(dSecurity);

Or you may refer this page
http://www.codeproject.com/KB/dotnet/adduseracetofile.aspx
Random Solutions  
 
programming4us programming4us