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

首頁 > 編程 > .NET > 正文

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

2024-07-10 13:10:28
字體:
來源:轉載
供稿:網友

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);
    }
}

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 玉环县| 江陵县| 沁阳市| 汶上县| 临湘市| 大名县| 平陆县| 舒兰市| 英山县| 刚察县| 稷山县| 沙河市| 石阡县| 鄢陵县| 静海县| 民乐县| 福清市| 定远县| 武安市| 莱芜市| 临泽县| 东乌| 鄂伦春自治旗| 仁怀市| 大姚县| 廉江市| 贵港市| 绥德县| 鲁山县| 贺兰县| 中宁县| 镇沅| 福贡县| 苍溪县| 女性| 宝丰县| 阿坝县| 礼泉县| 鄂温| 灵丘县| 武汉市|