📄 default.aspx
字号:
<%@ Page Language="C#" %>
<%@ 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 void Page_Load(object sender, EventArgs e)
{
// retrieve the AccessControl information for this file
System.Security.AccessControl.FileSecurity sec =
File.GetAccessControl(Server.MapPath("TextFile.txt"));
this.Label1.Text =
sec.GetOwner( typeof(System.Security.Principal.NTAccount) ).Value;
// retrieve the collection of access rules
AuthorizationRuleCollection auth =
sec.GetAccessRules(true, true, typeof(System.Security.Principal.NTAccount));
TableCell tc;
// loop through the rule collection and add a table row for each rule
foreach (FileSystemAccessRule r in auth)
{
TableRow tr = 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);
}
}
</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 + -