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 + "\\ASPNET", FileSystemRights.FullControl, AccessControlType.Allow));
dirinfo.SetAccessControl(dirsecurity);
}
}
Word教程网 | Excel教程网 | Dreamweaver教程网 | Fireworks教程网 | PPT教程网 | FLASH教程网 | PS教程网 |
HTML教程网 | DIV CSS教程网 | FLASH AS教程网 | ACCESS教程网 | SQL SERVER教程网 | C语言教程网 | JAVASCRIPT教程网 |
ASP教程网 | ASP.NET教程网 | CorelDraw教程网 |