Created
January 15, 2021 10:33
-
-
Save HainanZhao/38fa38146a9ff60b529228edc38f1ba2 to your computer and use it in GitHub Desktop.
Asp - Test Folder Rights
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <%@ Page Language="C#" AutoEventWireup="true" %> | |
| <%@ Import Namespace="System.IO" %> | |
| <!DOCTYPE html> | |
| <script runat="server"> | |
| protected void ButtonWho_Click(object sender, EventArgs e) | |
| { | |
| Label1.Text = System.Security.Principal.WindowsIdentity.GetCurrent().Name; | |
| } | |
| protected void ButtonTest_Click(object sender, EventArgs e) | |
| { | |
| Label1.Text = Directory.Exists(TextBox1.Text) ? "Exists" : "Not Exist"; | |
| } | |
| protected void ButtonCreate_Click(object sender, EventArgs e) | |
| { | |
| Label1.Text = System.Security.Principal.WindowsIdentity.GetCurrent().Name; | |
| try | |
| { | |
| Directory.CreateDirectory(TextBox1.Text); | |
| } | |
| catch (Exception ex) | |
| { | |
| Label1.Text = ex.ToString(); | |
| } | |
| } | |
| </script> | |
| <html xmlns="http://www.w3.org/1999/xhtml"> | |
| <head runat="server"> | |
| <title></title> | |
| </head> | |
| <body> | |
| <form id="form1" runat="server"> | |
| <div> | |
| <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> | |
| </div> | |
| <div> | |
| <asp:Label ID="Label1" runat="server"></asp:Label> | |
| </div> | |
| <p> | |
| <asp:Button ID="Button3" runat="server" Text="Who Am I" OnClick="ButtonWho_Click" /> | |
| <asp:Button ID="Button2" runat="server" Text="Test" OnClick="ButtonTest_Click" /> | |
| <asp:Button ID="Button1" runat="server" Text="Create" OnClick="ButtonCreate_Click" /> | |
| </p> | |
| </form> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment