当前位置: 首页 > news >正文

关于对文件路径权限判断的记录

首先需要添加引用

using System.Security.AccessControl;

以下为具体代码,其中fileServerPath为需要判断的文件路径

 #region Authority judgmentDirectorySecurity fileAcl = Directory.GetAccessControl(fileServerPath);var rules = fileAcl.GetAccessRules(true, true, typeof(System.Security.Principal.NTAccount)).OfType<FileSystemAccessRule>().ToList();var currentUser = Path.Combine(Environment.UserDomainName, Environment.UserName);bool permission = false;foreach (var rule in rules){if (rule.IdentityReference.ToString() == currentUser) permission = true;}PublicMethod.OutputParameterWriteToLog(MethodBase.GetCurrentMethod().Name, string.Format("Current user [{0}] [{1}] access to file path [{2}]", currentUser, (permission ? "have" : "does not have"), fileServerPath));
#endregion
http://www.lryc.cn/news/146295.html

相关文章:

  • git 基础
  • C语言网络编程实现广播
  • js对url进行编码解码(三种方式)
  • React面向组件编程
  • Linux 多线程同步机制(上)
  • C++学习vector
  • 17.3 【Linux】systemctl 针对 service 类型的配置文件
  • 融云获评「创业邦 · 最具创新价值出海服务商」
  • 【中危】Apache XML Graphics Batik<1.17 存在SSRF漏洞 (CVE-2022-44729)
  • AssemblyManager 程序集管理器
  • 几个nlp的小任务(生成式任务——语言模型(CLM与MLM))
  • 单元测试用例mock的使用方法
  • 3D步进式漫游能够在哪些行业应用?
  • 2023蓝帽杯初赛ctf部分题目
  • vue3+ts封装弹窗,分页封装
  • 2023-08-30 数据库-并发控制-冲突可串行化调度-是否可串行化检测-优先图-分析
  • 人员着装识别算法 yolo
  • Linux:权限
  • Unity记录4.3-存储-点击Tilemap保存或读取区块
  • 【小吉测评】哔哩哔哩接入AI?!效果如何?
  • 微信开发之一键踢出群聊的技术实现
  • 基于Spring Boot 的 Ext JS 应用框架之coworkee
  • HOT100打卡—day10—【DP+多维DP】—最新8.29(剩6题)
  • 【不会用这个工具,你的Linux服务器就是个摆设!】
  • 09 生产者分区机制
  • 亚马逊鲲鹏系统是怎么操作测评的
  • 电脑上的视频如何导入苹果手机?
  • tsmc standard cell命名规则
  • 基于ssm医院在线挂号预约系统源码和论文
  • mysql binlog 浅谈