【问题标题】:Restrict acces to a folder(and all its files and subdirectories) stored on a sd card C#限制对存储在 sd 卡 C# 上的文件夹(及其所有文件和子目录)的访问
【发布时间】:2012-05-26 20:38:15
【问题描述】:

嘿, 有没有办法限制对存储在 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);

    }

【问题讨论】:

  • 您可以尝试加密文件和子目录。
  • 目录限制权限示例:redmondpie.com/…

标签: c# directory sd-card rights


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2016-04-13
    • 2011-02-08
    • 2015-10-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-17
    • 1970-01-01
    相关资源
    最近更新 更多