我正在尝试将图像保存到.NET C#中的文件夹中,但收到以下异常:
Access to the path 'C:\inetpub\wwwroot\mysite\images\savehere' is denied.The error occured at mscorlib because at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode)
我把这个文件夹(savehere)的完全控制权交给了network service
和iis_iusrs
,甚至还给了everyone
完全控制权,但还是得到了这个异常。我尝试通过资源管理器和IIS管理器提供访问权限,但仍然没有成功
我是在WindowsServer2008 R2和IIS7.5上做的,我需要给谁访问权限?
发布于 2011-02-03 01:35:26
您需要从网站的应用程序池中找出它在什么身份下运行(默认情况下是Application Pool Identity
),并授予正确的权限。
发布于 2012-08-08 09:44:32
当我试图在服务器上创建一个文件(实际上是一个模板的副本)时,我也遇到了同样的问题。
下面是完整的错误消息:
{ERROR} 08/07/2012 22:15:58 - System.UnauthorizedAccessException: Access to the path 'C:\inetpub\wwwroot\SAvE\Templates\Cover.pdf' is denied.
我在IIS应用程序文件夹中添加了一个名为Templates
的新文件夹。在我的例子中有一件非常重要的事情,那就是我需要给IUSR用户对该文件夹的写(Gravar)权限。您可能还需要为Network Service
和ASP.NET v$.#
授予相同的写权限。
完成这项工作后,一切都按预期进行。
发布于 2013-02-26 09:28:33
我的问题是我只能请求只读访问权限:
FileStream fs = new FileStream(name, FileMode.Open, FileAccess.Read);
https://stackoverflow.com/questions/4877741
复制相似问题