C#:label的尺寸无法修改

展开阅读全文

C# 无法修改文件夹权限

10-30

在网上找到一段修改文件夹权限的代码rnrn在win7,和xp下都测试了,文件夹只增加了Everyone这个用户,没有赋予任何权限。rn我想使用C#修改文件夹的权限。rn请教,谢谢!rnrn用法: addpathPower("G:\test", "Everyone", "FullControl");rn//Everyone表示用户名rn//FullControl为权限类型rnrn[code=C#]#region 设置目录访问权限rn //// rn /// 为创建的临时文件分配权限rn /// rn /// rn /// rn /// FullControlrn /// rn public void addpathPower(string pathname, string username, string power)rn rn DirectoryInfo dirinfo = new DirectoryInfo(pathname);rn if ((dirinfo.Attributes & FileAttributes.ReadOnly) != 0)rn rn dirinfo.Attributes = FileAttributes.Normal;rn rn //取得访问控制列表rn DirectorySecurity dirsecurity = dirinfo.GetAccessControl();rn switch (power)rn rn case "FullControl":rn dirsecurity.AddAccessRule(new FileSystemAccessRule(username, FileSystemRights.FullControl, AccessControlType.Allow));rn dirinfo.SetAccessControl(dirsecurity); rn break;rn case "ReadOnly":rn dirsecurity.AddAccessRule(new FileSystemAccessRule(username, FileSystemRights.Read, AccessControlType.Allow));rn dirinfo.SetAccessControl(dirsecurity); rn break;rn case "Write":rn dirsecurity.AddAccessRule(new FileSystemAccessRule(username, FileSystemRights.Write, AccessControlType.Allow));rn dirinfo.SetAccessControl(dirsecurity); rn break;rn case "Modify":rn dirsecurity.AddAccessRule(new FileSystemAccessRule(username, FileSystemRights.Modify, AccessControlType.Allow));rn dirinfo.SetAccessControl(dirsecurity); rn break;rn rn rn #endregion[/code] 论坛

没有更多推荐了,返回首页