Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Security.AccessControl
- Public Class Form1
- Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
- Dim FilePath As String = "Test.txt"
- Dim UserAccount As String = "Everyone"
- Dim FileInfo As IO.FileInfo = New IO.FileInfo(FilePath)
- Dim FileAcl As New FileSecurity
- FileAcl.AddAccessRule(New FileSystemAccessRule(UserAccount, FileSystemRights.FullControl, AccessControlType.Allow))
- 'FolderAcl.SetAccessRuleProtection(True, False) 'uncomment to remove existing permissions
- FileInfo.SetAccessControl(FileAcl)
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment