我正在编写一个应用程序来管理用户对文件的访问。简而言之,我必须使用目录和文件权限来完成此任务。我们廉价的CEO没有文件管理系统...
不管怎样..。除了用户可以查看目录中的哪些文件,但实际上看不到文件的内容之外,我已经让一切正常工作了。(文件中可能包含敏感的HR数据。)
我尝试了FileSystemRights.ListDirectory,但这似乎也将ReadData设置为true (忽略MS文档)。我关闭了ReadData (读取文件的能力),突然再次无法访问该目录。这两者似乎是联系在一起的。
有什么想法可以设置哪些权限来实现这一点?
我当前的代码是:
SetSecurity(pth, usr, FileSystemRights.ListDirectory, AccessControlType.Allow);
...
public void SetSecurity(string dirName, string account,
FileSystemRights rights, AccessControlType controlType)
{
// Get a FileSecurity object that represents the
// current security settings.
DirectorySecurity dSecurity = Directory.GetAccessControl(dirName);
dSecurity.AddAccessRule(new FileSystemAccessRule(account, rights, controlType));
// Set the new access settings.
Directory.SetAccessControl(dirName, dSecurity);
}
谢谢。
--Jerry
https://stackoverflow.com/questions/429864
复制相似问题