To remove rule you can use RemoveAccessRule methods.
Here are sample Example.
C# Example :
If you open the file Properties dialog again, you see that the user has been removed from the Access
Control List.
Here are converted code for vb.net with automated tool.
Here are sample Example.
C# Example :
string strFilePath = "D:\\Others\\bookmarks.html";
System.Security.AccessControl.FileSecurity sec = System.IO.File.GetAccessControl(strFilePath);
sec.RemoveAccessRule(new System.Security.AccessControl.FileSystemAccessRule(@"Everyone", System.Security.AccessControl.FileSystemRights.FullControl, System.Security.AccessControl.AccessControlType.Allow));
System.IO.File.SetAccessControl(strFilePath, sec);
System.Security.AccessControl.FileSecurity sec = System.IO.File.GetAccessControl(strFilePath);
sec.RemoveAccessRule(new System.Security.AccessControl.FileSystemAccessRule(@"Everyone", System.Security.AccessControl.FileSystemRights.FullControl, System.Security.AccessControl.AccessControlType.Allow));
System.IO.File.SetAccessControl(strFilePath, sec);
If you open the file Properties dialog again, you see that the user has been removed from the Access
Control List.
Here are converted code for vb.net with automated tool.
string strFilePath = "D:\Others\bookmarks.html";
System.Security.AccessControl.FileSecurity sec = System.IO.File.GetAccessControl(strFilePath);
sec.RemoveAccessRule(new System.Security.AccessControl.FileSystemAccessRule(@"Everyone", System.Security.AccessControl.FileSystemRights.FullControl, System.Security.AccessControl.AccessControlType.Allow));
System.IO.File.SetAccessControl(strFilePath, sec);
System.Security.AccessControl.FileSecurity sec = System.IO.File.GetAccessControl(strFilePath);
sec.RemoveAccessRule(new System.Security.AccessControl.FileSystemAccessRule(@"Everyone", System.Security.AccessControl.FileSystemRights.FullControl, System.Security.AccessControl.AccessControlType.Allow));
System.IO.File.SetAccessControl(strFilePath, sec);
No comments:
Post a Comment