473,383 Members | 1,980 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,383 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 2330
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.