/// <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 + "\\aspnet", filesystemrights.fullcontrol, accesscontroltype.allow));

        dirinfo.setaccesscontrol(dirsecurity);
    }

posted on 2007-01-31 10:34  李佩亮  阅读(707)  评论(1编辑  收藏  举报