Set File access rule

后端 未结 1 1868
时光取名叫无心
时光取名叫无心 2021-01-13 10:13

The follow function works on windows XP, now im trying it with windows 7 it returns IdentityNotMappedException error what is wrong? i have also change the application reques

1条回答
  •  南笙
    南笙 (楼主)
    2021-01-13 10:30

    Try this instead in your code:

    accessdeny.SetAccessRule(
       new System.Security.AccessControl.FileSystemAccessRule(
       new SecurityIdentifier(WellKnownSidType.WorldSid, null),
       System.Security.AccessControl.FileSystemRights.FullControl,
       System.Security.AccessControl.AccessControlType.Deny));
    

    The error message says "could not be translated" - this is Windows telling you that when it tried to find a SID for the "Everyone" group (i.e. translate)...it couldn't find it by that name.

    One reason for that is when you are running Windows under a different locale. For instance in German the group is called "Jeder" instead.

    0 讨论(0)
提交回复
热议问题