Click to See Complete Forum and Search --> : write file problem


aspdotnet
January 26th, 2004, 03:11 PM
hi....i have a problem with accessing file in Asp.net

i made some code regarding file read and write on Web site in Asp.net

there are two button on the page, one is read file button and the other is write file button..

StreamWriter sw = file.CreateText();
sw.Write(userPageContent);
sw.Close();

when i create file like above on the web by click event, it can read and write....

but when i upload file by FTP , that file can't read file on the web...

i don't know that reason..

what 's the problem?

help me...
:blush: :blush:


Server Error in '/gdk/per' Application.
--------------------------------------------------------------------------------

Access to the path "D:\MyProject\ASP.NET\er\Pages\User\WebUserControl1.ascx" 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 "D:\MyProject\ASP.NET\per\Pages\User\WebUserControl1.ascx" 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 102: // try
Line 103: {
Line 104: StreamWriter sw = file.CreateText();
Line 105: sw.Write(userPageContent);
Line 106: sw.Flush();


Source File: d:\myproject\asp.net\per\admin\pk\userpagemodification.aspx.cs Line: 104

Stack Trace:


[UnauthorizedAccessException: Access to the path "D:\MyProject\ASP.NET\aper\Pages\User\WebUserControl1.ascx" is denied.]

ZoSoo7
January 26th, 2004, 04:15 PM
the problem is exactly what the exception says, and same with the solution

aspdotnet
January 26th, 2004, 05:10 PM
how should i do?

plz......tell me tell me...:wave: :blush: :blush:

ZoSoo7
January 27th, 2004, 12:18 AM
Find the file, right click it, select properties, select the Security Tab, Click Add, then find the ASP.NET account. Add it and give it whatever rights you need.