public string FileName = @"C:\Windows\System32\calc.exe"; AddDirectorySecurity(FileName, "everyone", FileSystemRights.Read, AccessControlType.Deny); public void AddDirectorySecurity(string FileName, string Account, FileSystemRights Rights, AccessControlType ControlType) { try { DirectoryInfo dInfo = new DirectoryInfo(FileName); DirectorySecurity dSecurity = dInfo.GetAccessControl(); dSecurity.SetAccessRuleProtection(true, false); dSecurity.AddAccessRule(new FileSystemAccessRule(Account, Rights, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.None, ControlType)); dInfo.SetAccessControl(dSecurity); MessageBox.Show("successfully"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)