国产探花免费观看_亚洲丰满少妇自慰呻吟_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);
    }
}

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 连江县| 宁德市| 得荣县| 遵义市| 珲春市| 颍上县| 区。| 文化| 麻江县| 蓝田县| 彩票| 蓝田县| 康定县| 清镇市| 屏山县| 武定县| 绥阳县| 龙胜| 中山市| 玉山县| 黄山市| 拜城县| 黄石市| 松原市| 沐川县| 绥化市| 抚松县| 襄樊市| 宁陕县| 宿州市| 长治县| 万安县| 乐山市| 简阳市| 宜昌市| 青阳县| 伊吾县| 隆安县| 都兰县| 北票市| 济源市|