471,321 Members | 1,704 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Access to path 'XYZ' is denied

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.ItemsCompaniesLi stBox.SelectedIndex].Value);

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,

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();
XmlElement temp;
XmlElement newAd = rotatorDom.CreateElement("Ad");

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

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

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

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

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

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/)

Jul 21 '05 #1
0 925

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Theerachet Pratoommanee | last post: by
4 posts views Thread by Fabian von Romberg | last post: by
reply views Thread by Chris McKenzie via .NET 247 | last post: by
3 posts views Thread by David Thielen | last post: by
1 post views Thread by cpajoe2001 | last post: by
8 posts views Thread by Jeremy Ames | 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.