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 9177443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:19:41+00:00 2026-06-17T17:19:41+00:00

During my game, you can save a map and store the tiles in the

  • 0

During my game, you can save a map and store the tiles in the map into a xml file.
So far no problem. The problem starts when I try to save it it gives me a UnauthorizedAccessException error somehow.

The folder is located in the installation dir of my game:

instal_dir/data/maps/

I checked to make sure, but the folder is created succesfully with the correct permissions (write, read and execute).

Am I doing something wrong?

Here is my code:

private void CreateXMLOfMap()
{
    List<Tile> tiles = mapContainer.GetTileList();
    XmlDocument doc = new XmlDocument();
    XmlNode docNode = doc.CreateXmlDeclaration("1.0", "UTF-8", null);
    doc.AppendChild(docNode);

    XmlNode rootNode = doc.CreateElement("Map");
    doc.AppendChild(rootNode);

    XmlNode mapName = doc.CreateElement("Name");
    mapName.AppendChild(doc.CreateTextNode("custom_map"));
    rootNode.AppendChild(mapName);

    XmlNode tilesNode = doc.CreateElement("Tiles");
    rootNode.AppendChild(tilesNode);

    for (int i = 0; i < tiles.Count; i++ )
    {
        XmlNode tileNode = doc.CreateElement("Tile");
        tilesNode.AppendChild(tileNode);

        XmlNode positionNode = doc.CreateElement("Position");
        tileNode.AppendChild(positionNode);
        XmlNode xNode = doc.CreateElement("X");
        xNode.AppendChild(doc.CreateTextNode(tiles[i].GetTilePosition().X.ToString()));
        positionNode.AppendChild(xNode);
        XmlNode yNode = doc.CreateElement("Y");
        yNode.AppendChild(doc.CreateTextNode(tiles[i].GetTilePosition().Y.ToString()));
        positionNode.AppendChild(yNode);

        XmlNode textureNode = doc.CreateElement("Texture");
        textureNode.AppendChild(doc.CreateTextNode(tiles[i].GetTileInfo().Name.ToString()));
        tileNode.AppendChild(textureNode);

        XmlNode YFrameNode = doc.CreateElement("YFrame");
        YFrameNode.AppendChild(doc.CreateTextNode(tiles[i].GetCurrentFrame().Y.ToString()));
        tileNode.AppendChild(YFrameNode);
    }

    doc.Save(Constants.MAPS_DIRECTORY);
}
  • 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-17T17:19:43+00:00Added an answer on June 17, 2026 at 5:19 pm

    Okay, so I found the problem that caused this exception to show up. It appeard that I only included the directory, but not the file name. So it tried to store the content into the directory, instead of into a xml file.

    All I had to change was to string that goes into

    doc.Save(PATH_TO_DIR_WITH_FILE_NAME);
    

    But I’ll keep in my, if I continue like this, I might end up needing administrator righs, so I’ll need to change it sooner or later.

    Thanks all for your advice and help!

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

Sidebar

Related Questions

I was wondering how low battery alerts can be handled during a game. I
I need to save some state when the user leaves my game during game
I am trying to make a game object that can be made semitransparent during
I'm writing a card game. I've encountered a problem and can't seem to figure
Let's assume I'm developing a AJAX, PHP chess game. During the game, one movement
For some reason during loading one of the scenes in my game, the background
I'm writing a 2D gravity simulation game and I'm trying to add save/load functionality.
Can someone write up a source for a program that just has a game
How can we check if the iphone has gone into a standby mode and
During the last 2 months I've been trying to learn the basics of game

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.