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