- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
FileInfo file = new FileInfo(fileName);
FileSecurity fSecurity = File.GetAccessControl(fileName);
foreach (FileSystemAccessRule permissions in fSecurity.GetAccessRules(true, true, typeof(NTAccount)))
{
string login = permissions.IdentityReference.Translate(typeof(NTAccount)).Value.ToString();
string permiss = permissions.FileSystemRights.ToString();
if ((login != "логин") && (login != "логин") && (login != "логин"))
{
fSecurity.SetAccessRuleProtection(true, false);
fSecurity.RemoveAccessRule(new FileSystemAccessRule(login, permissions.FileSystemRights, AccessControlType.Allow));
}
fSecurity.AddAccessRule(new FileSystemAccessRule("логин", FileSystemRights.FullControl, AccessControlType.Allow));
fSecurity.AddAccessRule(new FileSystemAccessRule("логин", FileSystemRights.FullControl, AccessControlType.Allow));
}
File.SetAccessControl(fileName, fSecurity);