Adding a rule to the Access Control List (VB) : Access Control « File Directory « ASP.NET Tutorial






<%@ Page Language="VB" %>
<%@ Import Namespace="System.IO" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim sec As System.Security.AccessControl.FileSecurity = _
         System.IO.File.GetAccessControl(Server.MapPath("Data.txt"))

        sec.AddAccessRule( _
                 New System.Security.AccessControl.FileSystemAccessRule( _
                          "DEMOXP\TestUser", _
                          System.Security.AccessControl.FileSystemRights.FullControl, _
                          System.Security.AccessControl.AccessControlType.Allow _
                          ) _
                 )

        File.SetAccessControl(Server.MapPath("Data.txt"), sec)

    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
    </div>
    </form>
</body>
</html>








10.10.Access Control
10.10.1.Access Control List information (C#)
10.10.2.Access Control List information (VB)
10.10.3.Adding a rule to the Access Control List (C#)
10.10.4.Adding a rule to the Access Control List (VB)
10.10.5.Removing the rule from the Access Control List (C#)
10.10.6.Removing the rule from the Access Control List (VB)