当前位置: 动力学知识库 > 问答 > 编程问答 >

c# - Get access permissions for a file for a current windows-user

问题描述:

How can I get access permissions for a file for the current user (user that runs the application) ?

public static DirectoryInfo di = new DirectoryInfo(rootPath);

var dirSecurity = di.GetAccessControl();

var accRules = dirSecurity.GetAccessRules(true, true, typeof(System.Security.Principal.NTAccount));

accRules contains array of FileSystemAccessRule. I guess these are the permissions for different roles.

How can I know which of them applies for the user that currently runs the application ?

分享给朋友:
您可能感兴趣的文章:
随机阅读: