ASP.NET ERROR

From: nilesh jadav via .NET 247 (anonymous_at_dotnet247.com)
Date: 03/07/05


Date: Mon, 07 Mar 2005 11:39:39 -0800

Server Error in '/FileUpload' Application.
--------------------------------------------------------------------------------

Access to the path "f:\MyFile.txt" is denied.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.UnauthorizedAccessException: Access to the path "f:\MyFile.txt" is denied.

ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

To grant ASP.NET write access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.

Source Error:

Line 37: lbl.Text = MyFile.PostedFile.FileName
Line 38: 'Save the file to the directory
Line 39: MyFile.PostedFile.SaveAs("f:\MyFile.txt")
Line 40:
Line 41: End Sub
 

Source File: C:\Inetpub\wwwroot\FileUpload\WebForm1.aspx.vb Line: 39

Stack Trace:

[UnauthorizedAccessException: Access to the path "f:\MyFile.txt" is denied.]
   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)
   FileUpload.WebForm1.btnSubmit_Click(Object sender, EventArgs e) in C:\Inetpub\wwwroot\FileUpload\WebForm1.aspx.vb:39
   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() +1277

 

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573
--------------------------------
From: nilesh jadav

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>PAUroRSWJEeLDNnyjLEcow==</Id>