PC Review


Reply
Thread Tools Rate Thread

Access to path 'XYZ' is denied

 
 
Chris McKenzie via .NET 247
Guest
Posts: n/a
 
      29th Mar 2005
I am trying to write an Ad Rotator component on my ASP.NET site,but keep running into an "interesting" problem. The routinestarts out by submitting the new ad information to the database(this part works fine), then attempts to write/append to astructured XML document (this is where it gets "interesting"). The system will attempt to write to the hard-coded XML documentand fail with the error message "Access to the path\"c:\\inetpub\\wwwroot\\H4\\Config\\AdRotator.Xml\" is denied.".However, the program will once again attempt the entire saveroutine (including writing to the DB, thereby duplicatingrecords), only this time it will write to the XML filecorrectly! Here is my code (in case it helps):

ASP.NET page
============
private void OKButton_Click(object sender, System.EventArgs e){
TheseAds.Business.Advertisement newAd = newTheseAds.Business.Advertisement();
newAd.ImageUrl = ImageURL.Text;
newAd.Description = Description.Text;
newAd.TrueNavigateUrl = NavigateURL.Text;
newAd.KeyWord = Keyword.Text;
newAd.AlternateText = AlternateText.Text;
newAd.CompanyID =Convert.ToInt32(CompaniesListBox.ItemsCompaniesListBox.SelectedIndex].Value);
newAd.Create();
Response.Redirect("Admin.aspx");
}

Business.Advertisement
======================
public void Create(){
HttpContext context = HttpContext.Current;
Configuration.ModuleSettings settings =Configuration.ModuleConfig.GetSettings();
Data.Advertisement newAd = newData.Advertisement(settings.ConnectionString);
newAd.Create(imageUrl, trueNavigateUrl, alternateText, keyword,companyId, description,
context.Server.MapPath(settings.RotatorXmlFile));
}

Data.Advertisement
==================
public void Create(string imageUrl, string trueNavigateUrl,string alternateText, string keyword, int companyId, stringdescription, string rotatorFile){
int rowsAffected;
SqlParameter[] parameters = { new SqlParameter("@companyID",SqlDbType.Int, 4),
new SqlParameter("@description", SqlDbType.VarChar, 255),
new SqlParameter("@trueNavigateUrl", SqlDbType.VarChar,255),
new SqlParameter("@adID", SqlDbType.Int, 4)};
parameters[0].Value = companyId;
parameters[1].Value = description;
parameters[2].Value = trueNavigateUrl;
parameters[3].Direction = ParameterDirection.Output;

RunProcedure("usp_Ads_CreateAdvertisement", parameters, outrowsAffected);

// now that the new ad is in the DB, put the rest of the detailsin the Rotator's XML file.
Configuration.ModuleSettings settings =Configuration.ModuleConfig.GetSettings();

XmlDocument rotatorDom = new XmlDocument();
rotatorDom.Load(rotatorFile);
XmlElement temp;
XmlElement newAd = rotatorDom.CreateElement("Ad");

temp = rotatorDom.CreateElement("ImageUrl");
temp.InnerText = imageUrl;
newAd.AppendChild(temp);

temp = rotatorDom.CreateElement("NavigateUrl");
temp.InnerText = settings.PassThroughPage + "?AD=" +parameters[3].Value.ToString();
newAd.AppendChild(temp);

temp = rotatorDom.CreateElement("AlternateText");
temp.InnerText = alternateText;
newAd.AppendChild(temp);

temp = rotatorDom.CreateElement("Keyword");
temp.InnerText = keyword;
newAd.AppendChild(temp);

temp = rotatorDom.CreateElement("Impressions");
temp.InnerText = "1";
newAd.AppendChild(temp);

rotatorDom.DocumentElement.AppendChild(newAd);
try{
rotatorDom.Save(rotatorFile);
}
catch(Exception ex){
throw new AppException(ex.Message);
}
}

Any help at all will be greatly appreciated.


--------------------------------
From: Chris McKenzie

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>1KviZ+ZSfUOdN9mCJJM5oQ==</Id>
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Access to Path Denied Martin Microsoft C# .NET 2 5th Sep 2008 01:35 AM
An exception occurred in the OnBeforeInstall event handler of <name> Access to the path <path> is denied. Andrzej Lipski Microsoft Dot NET 0 5th Oct 2007 04:24 PM
Access to path denied Cheryl Yaeger Microsoft Dot NET 1 23rd Nov 2006 07:34 AM
Access to the path is denied. Santosh Microsoft ASP .NET 1 16th Oct 2006 01:32 PM
Access to the path .... is denied j_stus@hotmail.com Microsoft ASP .NET 3 23rd May 2006 04:10 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:41 PM.