解决asp.net访问某个文件夹没有权限(转)
2013-04-06 11:31
429 查看
private void SetRight(string folderpath) { bool result = false; DirectoryInfo folder = new DirectoryInfo(folderpath); folder.Attributes |= FileAttributes.Normal; folder.Attributes &= ~FileAttributes.Hidden; // remove the folder Hidden attribute folder.Attributes &= ~FileAttributes.ReadOnly;// remove the folder ReadOnly attribute DirectorySecurity foldersecurity = new DirectorySecurity(); FileSystemAccessRule filerule = new FileSystemAccessRule("INTERACTIVE", FileSystemRights.FullControl, InheritanceFlags.ContainerInherit, PropagationFlags.InheritOnly, AccessControlType.Allow); FileSystemAccessRule filerule1 = new FileSystemAccessRule("NETWORK SERVICE", FileSystemRights.FullControl, InheritanceFlags.ContainerInherit, PropagationFlags.InheritOnly, AccessControlType.Allow); FileSystemAccessRule filerule2 = new FileSystemAccessRule("NETWORK", FileSystemRights.FullControl, InheritanceFlags.ContainerInherit, PropagationFlags.InheritOnly, AccessControlType.Allow); foldersecurity.ModifyAccessRule(AccessControlModification.Add, filerule, out result); foldersecurity.ModifyAccessRule(AccessControlModification.Add, filerule1, out result); foldersecurity.ModifyAccessRule(AccessControlModification.Add, filerule2, out result); folder.SetAccessControl(foldersecurity); }
注:folderpath为文件夹路径,将需要获得权限的文件夹路径传入方法即可。
相关文章推荐
- 当前标识(NT AUTHORITY\NETWORK SERVICE)没有对“c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files”的写访问权限 解决
- 解决(NT AUTHORITY/NETWORK SERVICE)没有对“C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files”的写访问权限。
- 当前标识没有对"Temporary ASP.NET Files"的写访问权限的解决办法
- 解决ASP.NET的进程帐户没有访问 IIS的权限
- .net程序出现没有对Temporary ASP.NET Files”的写访问权限解决方法
- .net程序出现没有对Temporary ASP.NET Files”的写访问权限解决方法
- IIS出现server application error+没有对“C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files”访问权限解决方法
- 解决ASP.NET 的进程帐户没有访问 IIS的权限[转]
- 当前标识没有对"Temporary ASP.NET Files"的写访问权限的解决办法
- 解决ASP.NET的进程帐户没有访问IIS的权限
- 如何解决xp文件夹权限,数据库只读,“ASP.NET 未被授权访问所请求的资源”
- 当前标识没有对"Temporary ASP.NET Files"的写访问权限的解决办法
- 解决ASP.NET的进程帐户没有访问IIS的权限
- 解决ASP.NET的进程帐户没有访问 IIS的权限
- IIS 之当前标识(NT AUTHORITY/NETWORK SERVICE)没有对“C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files”的写访问权限 问题的解决
- 当前标识没有对"Temporary ASP.NET Files"的写访问权限的解决办法
- IIS 之当前标识(NT AUTHORITY/NETWORK SERVICE)没有对“C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files”的写访问权限 问题的解决
- 解决ASP.NET 的进程帐户没有访问 IIS的权限
- 解决ASP.NET 的进程帐户没有访问 IIS的权限
- (iis,asp.net)Tip:错误"由于 ASP.NET 进程标识对全局程序集缓存没有读权限,因此未能执行请求。错误: 0x80070005 拒绝访问"的解决办法