繁体   English   中英

限制对存储在SD卡C#中的文件夹(及其所有文件和子目录)的访问

[英]Restrict acces to a folder(and all its files and subdirectories) stored on a sd card C#

嗨,有什么办法可以限制对存储在SD卡中的文件夹的访问? 我试过了,但是没有用...欢迎任何想法。 谢谢...

public static void setRight(string dirName,string account, FileSystemRights rights, AccessControlType controlType)
    {
        DirectoryInfo dir = new DirectoryInfo(dirName);

        DirectorySecurity dSecurity = new DirectorySecurity();// Directory.GetAccessControl(dirName);

        // Add the FileSystemAccessRule to the security settings.
        dSecurity.AddAccessRule(new FileSystemAccessRule(account, rights, controlType));

        // Set the new access settings.
        dir.SetAccessControl(dSecurity);
        Directory.SetAccessControl(dirName, dSecurity);

    }

尝试使用File.EncryptFile.Decrypt方法。 您可以使用递归来加密目录中的所有文件,从而对目录进行加密。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM