本文整理匯總了VB.NET中System.Security.AccessControl.FileSystemSecurity.RemoveAuditRule方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET FileSystemSecurity.RemoveAuditRule方法的具體用法?VB.NET FileSystemSecurity.RemoveAuditRule怎麽用?VB.NET FileSystemSecurity.RemoveAuditRule使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Security.AccessControl.FileSystemSecurity
的用法示例。
在下文中一共展示了FileSystemSecurity.RemoveAuditRule方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: FileExample
' 導入命名空間
Imports System.IO
Imports System.Security.AccessControl
Module FileExample
Sub Main()
Try
Dim FileName As String = "test.xml"
Console.WriteLine("Adding access control entry for " + FileName)
' Add the access control entry to the file.
AddFileAuditRule(FileName, "MYDOMAIN\MyAccount", FileSystemRights.ReadData, AuditFlags.Failure)
Console.WriteLine("Removing access control entry from " + FileName)
' Remove the access control entry from the file.
RemoveFileAuditRule(FileName, "MYDOMAIN\MyAccount", FileSystemRights.ReadData, AuditFlags.Failure)
Console.WriteLine("Done.")
Catch e As IOException
Console.WriteLine("Unable to open the file: " & e.Message)
Catch e As PrivilegeNotHeldException
Console.WriteLine("The current account does not have the correct privileges: " & e.Message)
End Try
Console.ReadLine()
End Sub
' Adds an ACL entry on the specified file for the specified account.
Sub AddFileAuditRule(ByVal FileName As String, ByVal Account As String, ByVal Rights As FileSystemRights, ByVal AuditRule As AuditFlags)
' Get a FileSecurity object that represents the
' current security settings.
Dim fSecurity As FileSecurity = File.GetAccessControl(FileName)
' Add the FileSystemAuditRule to the security settings.
fSecurity.AddAuditRule(New FileSystemAuditRule(Account, Rights, AuditRule))
' Set the new access settings.
File.SetAccessControl(FileName, fSecurity)
End Sub
' Removes an ACL entry on the specified file for the specified account.
Sub RemoveFileAuditRule(ByVal FileName As String, ByVal Account As String, ByVal Rights As FileSystemRights, ByVal AuditRule As AuditFlags)
' Get a FileSecurity object that represents the
' current security settings.
Dim fSecurity As FileSecurity = File.GetAccessControl(FileName)
' Add the FileSystemAuditRule to the security settings.
fSecurity.RemoveAuditRule(New FileSystemAuditRule(Account, Rights, AuditRule))
' Set the new access settings.
File.SetAccessControl(FileName, fSecurity)
End Sub
End Module