⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 default.aspx

📁 對c#初學者參考..為課題asp.net 2.0教材代碼
💻 ASPX
字号:
<%@ Page Language="VB" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Security.AccessControl" %>

<!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)
        ' retrieve the AccessControl information for this file
        Dim sec As System.Security.AccessControl.FileSecurity = System.IO.File.GetAccessControl(Server.MapPath("TextFile.txt"))
        
        Me.Label1.Text = _
                 sec.GetOwner(System.Type.GetType("System.Security.Principal.NTAccount")).Value
      
        ' retrieve the collection of access rules 
        Dim auth As AuthorizationRuleCollection = sec.GetAccessRules(True, True, System.Type.GetType("System.Security.Principal.NTAccount"))

        Dim tc As TableCell
        ' loop through the rule collection and add a table row for each rule
        For Each r As FileSystemAccessRule In auth
        
            Dim tr As New TableRow()
            
            tc = New TableCell()
            tc.Text = r.AccessControlType.ToString()  'deny or allow
            tr.Cells.Add(tc)

            tc = New TableCell()
            tc.Text = r.IdentityReference.Value  'who
            tr.Cells.Add(tc)

            tc = New TableCell()
            tc.Text = r.InheritanceFlags.ToString()
            tr.Cells.Add(tc)

            tc = New TableCell()
            tc.Text = r.IsInherited.ToString()
            tr.Cells.Add(tc)

            tc = New TableCell()
            tc.Text = r.PropagationFlags.ToString()
            tr.Cells.Add(tc)

            tc = New TableCell()
            tc.Text = r.FileSystemRights.ToString()
            tr.Cells.Add(tc)

            Table1.Rows.Add(tr)
        Next
    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>
        <p><b>File Owner:</b>
              <asp:Label ID="Label1" runat="server" Text="Label" /></p>        
        <p>
        Access Rules:<br />
        <asp:Table ID="Table1" runat="server" CellPadding="2" GridLines="Both">
            <asp:TableRow>
                <asp:TableHeaderCell>Control Type</asp:TableHeaderCell>
                <asp:TableHeaderCell>Identity</asp:TableHeaderCell>
                <asp:TableHeaderCell>Inheritance Flags</asp:TableHeaderCell>
                <asp:TableHeaderCell>Is Inherited</asp:TableHeaderCell>
                <asp:TableHeaderCell>Propagation Flags</asp:TableHeaderCell>     
                <asp:TableHeaderCell>File System Rights</asp:TableHeaderCell>
            </asp:TableRow>
        </asp:Table>
        </p>        
    
    </div>
    </form>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -