我有一个装有图片的图片框。我不想改变图片框的尺寸。我希望能够更改图像的宽度和高度,但为此我需要将其权限从readonly更改为read-write。我怎么能以编程方式做到这一点? 谢谢!
答案 0 :(得分:0)
试试这个:
using System.Security.AccessControl;
-
private void SetFullAccessAttribute(string fileName)
{
string path = fileName;
DirectorySecurity sec = Directory.GetAccessControl(path);
System.Security.Principal.SecurityIdentifier everyone = new System.Security.Principal.SecurityIdentifier(System.Security.Principal.WellKnownSidType.WorldSid, null);
sec.AddAccessRule(new FileSystemAccessRule(everyone, FileSystemRights.FullControl, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow));
Directory.SetAccessControl(path, sec);
}
P.S。为了成功执行上面的代码,您应该以提升的权限运行应用程序