The follow function works on Windows XP, now I'm trying it with Windows 7, it returns an IdentityNotMappedException error, what's wrong? I also changed the requestexecutionlevel application to admin.
private static void file_accessdeny(string fileName)
{
try
{
System.Security.AccessControl.FileSecurity accessdeny = System.IO.File.GetAccessControl(fileName);
accessdeny.SetAccessRule(new System.Security.AccessControl.FileSystemAccessRule("Everyone", System.Security.AccessControl.FileSystemRights.FullControl, System.Security.AccessControl.AccessControlType.Deny));
System.IO.File.SetAccessControl(fileName, accessdeny);
}
catch (System.Exception E)
{
Console.WriteLine(E.Message);
System.Windows.Forms.MessageBox.Show(E.Message, "access deny");
}
}
Error: System.Security.Principal.IdentityNotMappedException: some or all identifier references cannot be translated
source
share