[原]C#设置文件夹用户权限

var security = new DirectorySecurity();  
string path=@"C:\temp"
//设置权限的应用为文件夹本身、子文件夹及文件,所以需要InheritanceFlags.ContainerInherit 或 InheritanceFlags.ObjectInherit  
security.AddAccessRule(new FileSystemAccessRule("NETWORK SERVICE", FileSystemRights.FullControl, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow));  
security.AddAccessRule(new FileSystemAccessRule("Everyone", FileSystemRights.FullControl, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow));  
Directory.SetAccessControl(path, security);

作者:a497785609 发表于2014-3-18 12:52:25 原文链接
阅读:69 评论:0 查看评论
posted @ 2014-03-18 12:52  清山博客  阅读(322)  评论(0编辑  收藏  举报