c# 文件夹权限

/// <summary>
        /// 创建文件路径
        /// </summary>
        /// <param name="filepath"></param>
        /// <returns></returns>
        private void CreatePath(string filepath)
        {
            if (!Directory.Exists(filepath))
            {
                var securityRules = new DirectorySecurity();
                securityRules.AddAccessRule(new FileSystemAccessRule(System.Environment.UserName, FileSystemRights.FullControl, AccessControlType.Allow));
                securityRules.AddAccessRule(new FileSystemAccessRule("Everyone", FileSystemRights.FullControl, AccessControlType.Allow));
                securityRules.AddAccessRule(new FileSystemAccessRule("NETWORK SERVICE", FileSystemRights.FullControl, AccessControlType.Allow));
                Directory.CreateDirectory(filepath, securityRules);
            }

 

你可能感兴趣的