2
這裏有WellKnownSidType.WorldSid添加訪問規則是代碼:不能在Windows 7
var sid = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
var directorySecurity = new DirectorySecurity();
directorySecurity.AddAccessRule(new FileSystemAccessRule(sid, FileSystemRights.FullControl, AccessControlType.Allow));
Directory.CreateDirectory(Path.GetDirectoryName(this.PathToSettings.LocalPath), directorySecurity);
var fileSecurity = new FileSecurity();
fileSecurity.AddAccessRule(new FileSystemAccessRule(sid, FileSystemRights.FullControl, AccessControlType.Allow));
using (var fs = new FileStream(this.PathToSettings.LocalPath, FileMode.Create, FileSystemRights.FullControl, FileShare.None, 1024, FileOptions.None, fileSecurity))
{
var bytes = Encoding.UTF8.GetBytes(Resources.DefaultSettings);
fs.Write(bytes, 0, bytes.Length);
}
問題:在Windows 7上,這些訪問規則並不適用於文件(我看不出組Everyone
上Security
文件屬性對話框的頁面。
我想允許訪問指定的文件給大家(管理員,用戶,等等)。
我在做什麼錯誤?
我知道這是舊的,但你的問題的第一行回答我的。謝謝。 – Thumper