delete file access denied to the authorized folder(no way out)

Discussion in 'ASP .Net' started by nasirmajor@yahoo.com, Jul 17, 2006.

  1. Guest

    dear all,
    Please any urgent help regarding following code.
    i have the following code

    =================================================================
    public void Delete(Object sender, DataGridCommandEventArgs e)
    {
    1 int Sid2 = (int)l.DataKeys[e.Item.ItemIndex];


    2 //=======================

    3 SqlDataReader gr = null;
    4 string engpath2 = "";
    5 string arbpath2 = "";

    6 gr = db.GetReader("Select * from tbl_SubCat2 Where SId2="
    + Sid2 + "");

    7 if (gr.Read())
    8 {

    9 engpath2 = gr[5].ToString();
    10 arbpath2 = gr[6].ToString();

    11 }

    12 string strfnameeng = Server.MapPath(@"..\" + engpath2);
    13 string strfnamearb = Server.MapPath(@"..\" + arbpath2);


    14 File.Delete(strfnameeng);
    15 File.Delete(strfnamearb);
    16 gr.Close();

    17 //=================================

    18 db.SqlQuery = "Delete from tbl_SubCat2 Where SId2=" + Sid2 + "";

    19 db.RunQuery();
    20 DataBind();

    }

    =================================================================
    i want the delete command of data grid to delete both the database
    field and as well as the file releated to that field as well.

    now this is happening separately i.e if last three lines (lines
    18,19,20) are removed then file deletion code (line 3 to 16) gets
    executed successfully.

    and when lines (18,19,20) are again included then field gets deleted
    from the database but file could not be deleted and the following error
    is generated.

    =======
    Exception Details: System.UnauthorizedAccessException: Access to the
    path 'c:\inetpub\wwwroot\Alreef\' 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 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.
    ========


    i did go to inetmanager and right click my site and then set the
    permissions there but even then there is the same error.
    why the whole programme is not going together i.e why line 18,19,20 are
    causing errors when they are included with lines(3 to 16)

    Please any urgent help.
    Thanks in advance
     
    , Jul 17, 2006
    #1
    1. Advertising

  2. Guest

    problem solved

    answer was b/w the lines
     
    , Jul 17, 2006
    #2
    1. Advertising

  3. mausingh

    Joined:
    Nov 17, 2010
    Messages:
    1
    Hi. I runned into that problem too. And after days of searching I finally found
    this software: Delete Long Path File Tool.

    It's GREAT. You can find it here: longpathtool
     
    mausingh, Nov 19, 2010
    #3
    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. Brent Burkart
    Replies:
    2
    Views:
    7,006
    Danish
    Jun 19, 2007
  2. Brent Burkart

    ASP.NET is not authorized to access

    Brent Burkart, Dec 4, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    742
    Brent Burkart
    Dec 5, 2003
  3. Mike McCann
    Replies:
    1
    Views:
    7,942
  4. Jay
    Replies:
    2
    Views:
    1,118
  5. antony beula
    Replies:
    0
    Views:
    723
    antony beula
    Feb 3, 2010
Loading...

Share This Page