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
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.