如何通过 C#.NET 在 FAT 文件系统中为文件和文件夹提供安全性
我在 C#.NET 中创建了一个文件夹锁,它在 NTFS 文件系统上运行良好,但在 FAT 文件系统上不起作用。请告诉我应该使用哪个 dll/类/命名空间通过与
NTFS 一起使用的 C#.NET 示例代码来获取 FAT 文件系统上的锁定文件和文件夹(下面的代码是解锁文件/文件夹)
FileInfo info = new FileInfo(folderpath);
FileSecurity accessControl = info.GetAccessControl(AccessControlSections.All);
accessControl.RemoveAccessRule(
new FileSystemAccessRule(
Environment.UserName.ToString(),
FileSystemRights.FullControl,
AccessControlType.Deny));
accessControl.SetSecurityDescriptorSddlForm(
"D:(A;;GAGRGWGXRCSDWDWORPWPCCDCLCSWLODTCR;;;WD)",
AccessControlSections.All);
info.SetAccessControl(accessControl);
I have created a folder lock in C#.NET which is working good on NTFS file system But its not working on FAT file system. please tell which dll/class/namespace should i use to get Lock files and folder on FAT file system through C#.NET
sample code which is working with NTFS (below code is to unlock file/folder)
FileInfo info = new FileInfo(folderpath);
FileSecurity accessControl = info.GetAccessControl(AccessControlSections.All);
accessControl.RemoveAccessRule(
new FileSystemAccessRule(
Environment.UserName.ToString(),
FileSystemRights.FullControl,
AccessControlType.Deny));
accessControl.SetSecurityDescriptorSddlForm(
"D:(A;;GAGRGWGXRCSDWDWORPWPCCDCLCSWLODTCR;;;WD)",
AccessControlSections.All);
info.SetAccessControl(accessControl);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你不能。 FAT 文件系统不支持许多高级功能,例如访问控制列表。 (基本上,唯一类似于 FAT 中的访问控制的功能是“只读”文件属性位,它适用于每个用户)
You cannot. The FAT file system does not support many advanced features, such as access control lists. (Basically the only feature resembling access control in FAT is the "read only" file attribute bit, which applies to every user)
FAT 文件系统不支持安全性,因此您无法按照问题中说明的方式设置 ACL。
更多详细信息,请访问维基百科
The FAT file system does not support security so you are not able to set ACLs in the way you illustrate in your question.
More details can be found at Wikipedia