problem in creating a folder..

Discussion in 'ASP .Net Datagrid Control' started by NagaKiran, Jan 22, 2005.

  1. NagaKiran

    NagaKiran Guest

    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
     
    NagaKiran, Jan 22, 2005
    #1
    1. Advertising

  2. NagaKiran

    Elton Wang Guest

    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




    >-----Original Message-----
    >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
    >
    >
    >
    >
    >
    >
    >
    >.
    >
     
    Elton Wang, Jan 22, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. THY
    Replies:
    3
    Views:
    2,943
    Alvin Bruney
    Oct 16, 2003
  2. William LaMartin

    _vti_cnf folder in the bin folder-- a problem?

    William LaMartin, Nov 10, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    1,703
    Oliver
    Nov 10, 2003
  3. Dan
    Replies:
    7
    Views:
    18,580
    catherine sea
    Oct 28, 2010
  4. Jon Maz
    Replies:
    12
    Views:
    4,800
    Vadim Chekan
    Jul 1, 2004
  5. madhu
    Replies:
    0
    Views:
    418
    madhu
    Oct 5, 2006
Loading...

Share This Page