国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

Asp.net給站點某目錄增加Aspnet用戶

2024-07-10 12:40:48
字體:
來源:轉載
供稿:網友

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.IO;
using System.Net;
using System.Security.AccessControl;
using System.Security.Principal;

public partial class ACLChange : System.Web.UI.Page
{
    //文件夾路徑
    private string strDir = "images";

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            AddDirectorySecurity();
        }
    }

    /// <summary>
    /// 給文件夾添加ASPNET用戶
    /// </summary>
    private void AddDirectorySecurity()
    {
        DirectoryInfo dirinfo = new DirectoryInfo(Server.MapPath(strDir));

        if ((dirinfo.Attributes & FileAttributes.ReadOnly) != 0)
        {
            dirinfo.Attributes = FileAttributes.Normal;
        }

        //取得訪問控制列表
        DirectorySecurity dirsecurity = dirinfo.GetAccessControl();

        string strDomain = Dns.GetHostName();

        dirsecurity.AddAccessRule(new FileSystemAccessRule(strDomain + "http://ASPNET", FileSystemRights.FullControl, AccessControlType.Allow));

        dirinfo.SetAccessControl(dirsecurity);
    }
}

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 综艺| 罗甸县| 射阳县| 永吉县| 孝昌县| 桂平市| 临泉县| 灵寿县| 奉节县| 依安县| 乌审旗| 游戏| 百色市| 彭泽县| 甘孜县| 自贡市| 上蔡县| 略阳县| 通化县| 丰原市| 辛集市| 邮箱| 韶关市| 增城市| 团风县| 万盛区| 鄂尔多斯市| 玉林市| 丘北县| 铜川市| 尼玛县| 临潭县| 安泽县| 贞丰县| 富锦市| 响水县| 天津市| 南宫市| 社旗县| 岐山县| 霞浦县|