[已关闭问题]
关闭于 2008-05-15 15:24
<P>根据网上查询,写了一个如下的方法:</P>
<P>public bool AddpathPower(string pathname, string username, string power)<BR> {</P>
<P> try<BR> {<BR> DirectoryInfo dirinfo = new DirectoryInfo(pathname);</P>
<P> if ((dirinfo.Attributes & FileAttributes.ReadOnly) != 0)<BR> {<BR> dirinfo.Attributes = FileAttributes.Normal;<BR> }</P>
<P> //取得访问控制列表<BR> DirectorySecurity dirsecurity = dirinfo.GetAccessControl();</P>
<P> switch (power)<BR> {<BR> case "FullControl":<BR> dirsecurity.AddAccessRule(new FileSystemAccessRule(username, FileSystemRights.FullControl, InheritanceFlags.ObjectInherit, PropagationFlags.InheritOnly, AccessControlType.Allow));<BR> break;<BR> case "ReadOnly":<BR> dirsecurity.AddAccessRule(new FileSystemAccessRule(username, FileSystemRights.Read, AccessControlType.Allow));<BR> break;<BR> &am