对文件夹设置为Everyone的权限,首先需要先添加引用

using System.Security.AccessControl;

采用下面的方法对文件夹设置Everyone权限

 
        /// <summary>
        /// 设置文件夹权限,处理为Everyone所有权限
        /// </summary>
        /// <param name="foldPath">文件夹路径</param>
        public static void SetFileRole(string foldPath)
        {
            DirectorySecurity fsec = new DirectorySecurity();
            fsec.AddAccessRule(new FileSystemAccessRule("Everyone", FileSystemRights.FullControl,
                InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow));
            System.IO.Directory.SetAccessControl(foldPath, fsec);
        }    

 

另外也可以参考下http://www.cnblogs.com/leosky2008/archive/2007/08/08/847405.html

相关文章:

  • 2022-12-23
  • 2021-12-10
  • 2018-09-09
  • 2022-01-11
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-24
  • 2022-02-27
  • 2022-02-26
  • 2022-01-27
  • 2022-12-23
  • 2021-09-20
  • 2021-09-17
相关资源
相似解决方案