title: How to write a datarow to a xml file
body: <p>Here is the story. I was doing a program, every time the program is closed all the data(File links) created by the user is lost, so whenever the user reopen the program, he does have to do all the work again.</p>
  
  <p>So I decided to use an xml file to store the data, because a dbms would take too long to load and code to handle a plain text file would be hard to maintain.</p>
  
  <p>The data is mainly composed of Links that stores two file paths, one for the origin and one for the destination, one boolean that represent the state of the link before the program is closed, and a few other less important things.</p>
  
  <p>When the program loads the data should be read restoring the previous state of the application.</p>
  
  <p>So I made a xml file like this:</p>
  
  <pre><code>...
    &lt;Directories&gt;
      &lt;Directory id="0"&gt;
        &lt;FilePath&gt;C:\Test1&lt;/FilePath&gt;
        &lt;PathSeparator&gt;\&lt;/PathSeparator&gt;
      &lt;/Directory&gt;
  ...
  </code></pre>
  
  <p>And used a DataSet to get the data.</p>
  
  <pre><code>Directory getDirectory()
  {
      ds = new DataSet();
                  ds.ReadXml(xmlPath);
      DataRow[] myRow = ds.Tables["Directory"].
                  Select("id ="+id.ToString());// "id = id"
      string temp = myRow[0]["FilePath"].ToString();
      Directory result = new Directory();
      result.path = temp;
      temp = myRow[0]["PathSeparator"].ToString();
      result.pathSeparator = temp[0];
      return result;
  }
  </code></pre>
  
  <p>All that works just fine, but then I tried to add new "rows" to the xml:</p>
  
  <pre><code>public static int addDirectory(DataSet ds, char pathSeparator, string path)
  {
      DataRow myRow = ds.Tables["Directory"].NewRow();
      myRow.ItemArray[0] = 8;
      myRow.ItemArray[1] = path;
      myRow.ItemArray[2] = pathSeparator.ToString();
      myRow.ItemArray[3] = "lol";
      ds.Tables["Directory"].Rows.Add(myRow);
      ds.AcceptChanges();
      ds.WriteXml(ApplicationDataManager.xmlPath);
      return 8;
  }
  </code></pre>
  
  <p>But all this writes is  to a random place on the .xml</p>
  
  <p>What am I doing wrong?</p>
  
  <p>By the way if anyone have any suggestions about how I should store that data, I would be glad to hear(read).</p>
  
  <p>Thanks in advance!</p>
  
  <p>[Update]
  File Links are used to create a connection between two directories, so they can be synchronized.</p>