XiaoHui.Net 笑汇程序员论坛.Net 讨论区

   对路径“C:\Inetpub\wwwroot\test\upload”的访问被拒绝。


页: [1]

龙主人2007-12-29 08:17
对路径“C:\Inetpub\wwwroot\test\upload”的访问被拒绝。

请教各位大侠一个问题。我现在正在做一个文件上传的页面,目的地是本地硬盘。为什么我单击上传按钮以后他会提示这样的问题。我用的是windows2000系统。

对路径“C:\Inetpub\wwwroot\test\upload”的访问被拒绝。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.UnauthorizedAccessException: 对路径“C:\Inetpub\wwwroot\test\upload”的访问被拒绝。

ASP.NET 未被授权访问所请求的资源。请考虑授予 ASP.NET 请求标识访问此资源的权限。ASP.NET 有一个在应用程序没有模拟时使用的基进程标识(通常,在 IIS 5 上为 {MACHINE}\ASPNET,在 IIS 6 上为网络服务)。如果应用程序正在通过 <identity impersonate="true"/> 模拟,则标识将为匿名用户(通常为 IUSR_MACHINENAME)或经过身份验证的请求用户。

若要授予 ASP.NET 对文件的写访问权,请在资源管理器中右击该文件,选择“属性”,然后选择“安全”选项卡。单击“添加”添加适当的用户或组。突出显示 ASP.NET 帐户,选中所需访问权限对应的框。

源错误:


行 74:                 DateTime now=DateTime.Now;
行 75:                                 string newfile=now.DayOfYear.ToString()+file.PostedFile.ContentLength.ToString();
行 76:                                 file.PostedFile.SaveAs("C:\\Inetpub\\wwwroot\\test\\upload");
行 77:                 fname.Text=file.PostedFile.FileName;
行 78:                                 fenc.Text=file.PostedFile.ContentType;


源文件: c:\inetpub\wwwroot\test\go.aspx.cs    行: 76

堆栈跟踪:


[UnauthorizedAccessException: 对路径“C:\Inetpub\wwwroot\test\upload”的访问被拒绝。]
   System.IO.__Error.WinIOError(Int32 errorCode, String str) +393
   System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean bFromProxy) +888
   System.IO.FileStream..ctor(String path, FileMode mode) +52
   System.Web.HttpPostedFile.SaveAs(String filename)
   test.go.Button1_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\test\go.aspx.cs:76
   System.Web.UI.WebControls.Button.OnClick(EventArgs e)
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
   System.Web.UI.Page.ProcessRequestMain()




--------------------------------------------------------------------------------
版本信息: Microsoft .NET Framework 版本:1.1.4322.573; ASP.NET 版本:1.1.4322.573


我在网上找了好多关于此问题的资料,但是都没有解决。请各位大侠给指点一上。小弟在先此谢过了。

[[i] 本帖最后由 龙主人 于 2007-12-29 14:05 编辑 [/i]]


loveasy2008-7-15 05:39
权限不够啊 ·


查看完整版本: 对路径“C:\Inetpub\wwwroot\test\upload”的访问被拒绝。