problem in creating a folder..

N

NagaKiran

Hi

I have been worked with DotNet windows application.
There I didnot get this problem..

When I am working on web application, It is giving problem. I describing the
problem here.


I want to create a folder.

For this I have imported System.IO namespace..

Imports System.IO

To create a directory I am using the Directory class which is defined in
above mentioned namespace.
If Not Directory.Exists(Server.MapPath("\Projects")) Then

Directory.CreateDirectory(Server.MapPath("\Projects"))

End If



I wrote that code in page_load event..

When I tried to run the application it is giving the following error.

How to overcome this..

It seems like a simple one.. But kindly help me in this...

Thanks in advance

NagaKiran

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

Access to the path "c:\inetpub\wwwroot\Projects" 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
"c:\inetpub\wwwroot\Projects" 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 104:
Line 105: If Not Directory.Exists(Server.MapPath("\Projects")) Then
Line 106: Directory.CreateDirectory(Server.MapPath("\Projects"))
Line 107: End If
Line 108: If Not Directory.Exists(proLocation) Then

Source File: E:\Projects\pms\NES\pmsAddNewProj.aspx.vb Line: 106
 
E

Elton Wang

Hi NagaKiran,

In windows application the application works in a account
of login user. Mostly login user has permission of full
control to operating computer. On the other hand, the web
application works in a special account, ASPNET. If you
don't give the account permissions to access, create, or
delete, when conduct those kinds of opertions it will
cause UnauthorizedAccessException.

Hope it helps,

Elton Wang

(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,816
Latest member
nipsseyhussle

Latest Threads

Top