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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:51:00+00:00 2026-06-11T18:51:00+00:00

In my Isolated storage I have a file called Route.gpx which is getting created

  • 0

In my Isolated storage I have a file called Route.gpx which is getting created with this code:

using (IsolatedStorageFileStream myStream = new IsolatedStorageFileStream("Route.gpx", FileMode.Create, myStore))
{
    XNamespace ns = "http://www.topografix.com/GPX/1/1";
    XNamespace xsiNs = "http://www.w3.org/2001/XMLSchema-instance";
    XDocument xDoc = new XDocument(
        new XDeclaration("1.0", "UTF-8", "no"),
        new XElement(ns + "gpx",
            new XAttribute(XNamespace.Xmlns + "xsi", xsiNs),
            new XAttribute(xsiNs + "schemaLocation",
                "http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"),
            new XAttribute("creator", "XML tester"),
            new XAttribute("version", "1.1"),
            new XElement(ns + "trk",
                new XElement(ns + "trkseg",
                    new XElement(ns + "trkpt",
                        new XAttribute("lat", "7.0"),
                        new XAttribute("lon", "19.0"),
                        new XElement(ns + "time", DateTime.Now.ToString("yyyy-MM-ddThh:mm:ssZ", System.Globalization.CultureInfo.InvariantCulture))
                        )))));
    xDoc.Save(myStream);

But now I want to add an extra trkpt element, I’ve tried with this code:

XDocument doc1;
using (IsolatedStorageFileStream myStream = new IsolatedStorageFileStream("Route.gpx", FileMode.Open, myStore))
{
    doc1 = XDocument.Load(myStream);
}

var root = doc1.Element("trkseg");
var rows = root.Descendants("trkpt");
var lastRow = rows.Last();
lastRow.AddAfterSelf(
//XElement trkseg =
      new XElement("trkpt",
          new XElement("time", DateTime.Now.ToString("yyyy-MM-ddThh:mm:ssZ", System.Globalization.CultureInfo.InvariantCulture))));

using (IsolatedStorageFileStream myStream = new IsolatedStorageFileStream("Route.gpx", FileMode.Create, myStore))
{
    doc1.Save(myStream);
}

which I got from here
The code just catch an exception then pressed.

  • 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-11T18:51:01+00:00Added an answer on June 11, 2026 at 6:51 pm

    You’re trying to access the “trkseg” element as a descendent of the root object while you’re creating it at a level lower.

    Try:

    var root = doc1.Element("trk").Element("trkseg"); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created on application which creates a file in isolated storage . Now
Hi In my application i have created a text file in isolated storage and
I have created a text file in isolated storage. Now when i test it
I have a problem with isolated storage. This is my code: List<Notes> data =
I have problems in using SharpZipLib with isolated storage in WP7 to zip subfolders
I need to play music file from the isolated storage. i did by this
I have created a .net application that is currently using a encrypted text file
I am using IsolatedStorageSettings.ApplicationSettings for my application. All code associated with Isolated storage occurs
I have an requirement of store and retrieve data from isolated storage file.I will
I need to read a file from isolated storage (IsolatedStorageFileStream) as fast as possible.

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.