対象となるディレクトリのみにアクセス権を追加した場合はこの記事で紹介する方法でアクセス権を削除できますが、
アクセス権が親フォルダから継承されている場合はこの方法では削除できません。
継承されているディレクトリのアクセス権を削除する方法はこちらの記事を参照して下さい。
private void button7_Click(object sender, EventArgs e)
{
string filePath = @"c:\\develop\dev";
DirectoryInfo di = new DirectoryInfo(filePath);
FileSecurity security = FileSystemAclExtensions.GetAccessControl(di);
security.PurgeAccessRules(new NTAccount("everyone"));
FileSystemAclExtensions.SetAccessControl(di, security);
}
DirectoryInfo di = new DirectoryInfo(filePath);
FileSecurity security = FileSystemAclExtensions.GetAccessControl(di);
security.PurgeAccessRules(new NTAccount("everyone"));
FileSystemAclExtensions.SetAccessControl(di, security);
private void button_Remove_AccessRights(object sender, EventArgs e)
{
string filePath = @"c:\\develop\dev";
FileSecurity security = File.GetAccessControl(filePath);
security.PurgeAccessRules(new NTAccount("everyone"));
File.SetAccessControl(filePath, security);
}
FileSecurity security = File.GetAccessControl(filePath);
security.PurgeAccessRules(new NTAccount("everyone"));
File.SetAccessControl(filePath, security);