这是代码:
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
我想允许每个人(管理员、用户等)访问指定的文件。
我做错了什么?