[英]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.