簡體   English   中英

如何使用C#授予對文件夾和子文件夾中的所有文件的讀取訪問權限?

[英]How to grant read access to all files in a folder and subfolders using c#?

如何使用C#授予對Windows 7中的文件夾和子文件夾中的所有文件的讀取訪問權限?

我沒有一些文件,但是我擁有管理權限。

DirectoryInfo dirInfo = new DirectoryInfo(@"c:\yourDir");
DirectorySecurity dirSecurity = dirInfo.GetAccessControl();

dirSecurity.AddAccessRule(new FileSystemAccessRule
    (Enviroment.Username,
    FileSystemRights.ReadData, AccessControlType.Allow));

dirInfo.SetAccessControl(dirSecurity);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM