Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8351605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:41:02+00:00 2026-06-09T08:41:02+00:00

I have been testing my code to save into an XML file locally and

  • 0

I have been testing my code to save into an XML file locally and it is working fine. However i have just uploaded it to my server and it is not working. I changed the path to the path of the xml file but still no luck. This is my local code…

public void AddNodeToXMLFile(string XmlFilePath, string NodeNameToAddTo)
    {
        //create new instance of XmlDocument
        XmlDocument doc = new XmlDocument();

        //load from file
        doc.Load(XmlFilePath);

        //create main node
        XmlNode node = doc.CreateNode(XmlNodeType.Element, "Level", null);

        //create the nodes first child
        XmlNode mapname = doc.CreateElement("map");
        //set the value
        mapname.InnerText = mapsave.Value;

        // add childes to father
        node.AppendChild(mapname);

        // find the node we want to add the new node to
        XmlNodeList l = doc.GetElementsByTagName(NodeNameToAddTo);
        // append the new node
        l[0].AppendChild(node);
        // save the file
        doc.Save(XmlFilePath);
    }

protected void btnSave_Click(object sender, EventArgs e)
    {
        if (mapsave.Value.ToString() == "")
        {
            lblResult.Text = lblError.Value;
        }
        else
        {
            AddNodeToXMLFile("C:\\Users\\Glen.Robson\\Documents\\Visual Studio 2010\\Projects\\Project1\\Project1\\Scripts\\UserMaps.xml", "TileMaps");
        }

    }

So when i uploaded to the server i changed the path of AddNodeToXMLFile() to:

"http://www.mydomain.com/Scripts/UserMaps.xml"

But this does not work… Can anyone tell me what the file path should be?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T08:41:03+00:00Added an answer on June 9, 2026 at 8:41 am

    You cannot change the path to a URL… the code on the server still needs to know the physical path to the file on the server. It cannot work out where the file is based on a URL.

    Why don’t you use an application specific path…

    AddNodeToXMLFile(VirtualPathUtility.ToAbsolute("~/Scripts/UserMaps.xml"),"TileMaps");
    

    Then in your function, you need to “map” the virtual path into an actual physical path on the server…

    public void AddNodeToXMLFile(string XmlFilePath, string NodeNameToAddTo)
    {
       XmlFilePath = Server.MapPath(XmlFilePath);
       ...
    

    Also, you need to make sure that permissions are setup on the server correctly – meaning that the process that the ASP.NET application is running on IIS with, has the ability to write to the directly

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been testing my application on 32 bit and it is working fine
I have been testing the performance of reading server socket input stream. I found
I have been looking into integrating testing into my app based on RequireJS. I
I have been testing out some code and I need to load day view
I have been hacking on the code for Xournal in order to add auto-save
Since the iOS 5 Betas I have been testing my app's code and the
I have been trying to learn how to add testing to existing code --
I have been testing and playing around with jquery date picker below. http://jqueryui.com/demos/datepicker/ on
I created an app and have been testing it against targetSdk 14. The spinner
I have been recently testing my app in a strict mode to detect disk

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.