日期:2014-05-16 浏览次数:20999 次
try
{
var dir = new DirectorySecurity();
DirectoryInfo info = Directory.CreateDirectory(
path: @"d:\abc",
directorySecurity: dir);
info.Create();
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
DirectorySecurity securityRules = new DirectorySecurity();
securityRules.AddAccessRule(new FileSystemAccessRule(@"Domain\account1", FileSystemRights.Read, AccessControlType.Allow));
securityRules.AddAccessRule(new FileSystemAccessRule(@"Domain\account2", FileSystemRights.FullControl, AccessControlType.Allow));
DirectoryInfo di = Directory.CreateDirectory(@"C:\destination\NewDirectory", securityRules);