Пʼятниця, 13 липня 2007 р.

NTFS Permissions

Як програмно дати ASPNET користувачу права на запис в папку?


DirectoryInfo di = new DirectoryInfo(path);
if (di.Exists)
{
DirectorySecurity ds = di.GetAccessControl();
FileSystemAccessRule fsar = new FileSystemAccessRule(
new NTAccount(Environment.MachineName + "\\ASPNET"),
FileSystemRights.Write | FileSystemRights.ReadAndExecute |
FileSystemRights.Read, AccessControlType.Allow);
ds.AddAccessRule(fsar);
di.SetAccessControl(ds);
}