private void button1_Click(object sender, EventArgs e) { string fileName = @"E:\kkk.txt"; WindowsIdentity ident = WindowsIdentity.GetCurrent(); WindowsPrincipal user = new WindowsPrincipal(ident); AddFileSecurity(fileName, user.Identity.Name, FileSystemRights.Delete, AccessControlType.Deny); } public static void AddFileSecurity(string fileName, string account, FileSystemRights rights, AccessControlType controlType) { FileSecurity fSecurity = File.GetAccessControl(fileName); fSecurity.AddAccessRule(new FileSystemAccessRule(account, rights, controlType)); File.SetAccessControl(fileName, fSecurity); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)