471,118 Members | 1,083 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,118 software developers and data experts.

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

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 '06 #1
1 2149
problem solved

answer was b/w the lines

Jul 17 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by pembed2003 | last post: by
reply views Thread by Babu Mannaravalappil | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.