How to provide security to files and folders throu

2019-08-27 23:12发布

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);

2条回答
何必那么认真
2楼-- · 2019-08-27 23:36

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

查看更多
贪生不怕死
3楼-- · 2019-08-27 23:43

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)

查看更多
登录 后发表回答