473,232 Members | 1,414 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,232 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 2319
problem solved

answer was b/w the lines

Jul 17 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ibon Uria | last post by:
I am trying to create an ASP.NET application, but I am not able to specify the folder in which I want the application files to be phisically stored. Visual Studio only lets me to especify an...
6
by: pembed2003 | last post by:
Hi all, Given something like: std::ofstream out_file("path"); how do I extract the file descriptor from out_file? Is it possible? What I want is to extract the file descriptor and then pass...
2
by: Mark | last post by:
Hello! I am working on a project that requires the inclusion of an access database in a resource file. (VB.NET). It works OK when the db file size is under 200 MB but creates an OutOfMemory...
0
by: Babu Mannaravalappil | last post by:
Hi all, I apologize for posting this question on two groups. I did not know which one out of "XML" and "ADONET" groups, should I post this. I would like to create an xsd file out of an...
1
by: AlsMess | last post by:
I need to deliver a laptop equipped with Win XP OS, and I am obliged to instyall MsAcess 97 instead of a most recent. Now I have a Out of Memory message. We added Office97 patches and Jet 4...
3
by: jobs | last post by:
I've got a gridview that does not have a datasourceid assigned in the markup. I'd like to switch between two datasources in the codebehind. when I do switch, I first reset the the...
2
by: Venkatesh Muthusami | last post by:
Could you pls help me in fixing the 'out of memory' error while accessing the access db using a form.
5
by: Mon Ange | last post by:
Hi everyone, Although I do have some experience with Access I encounter a problem, which I could not solve yet. All search on the net did not bring up any result either, so I hope that someone in...
1
by: madan agarwal | last post by:
HI All, I have one database that cantain 10 primary file(.mdf and .ndf) and out of it 1 file get corruptted. My backup shedule: Full backup in sunday day at 7 PM. And differential backup at...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.