I am developing an app that saves some values initially for settings and after usage, it automatically delete them and save the XML file again. I am using the below code, the app load the XML but its not deleting the node nor saving the file. Can anyone help me to this.
XDocument definitionFile = XDocument.Load(@"definitions.xml");
XDocument definitionFile = XDocument.Load(@"definitions.xml");
var wordset = definitionFile.Descendants("wordset");
int wordsetCount = wordset.Count();
var randomWord = (from word in definitionFile.Descendants("wordset")
select word).OrderBy(r => rnd.Next(0, wordsetCount - 1)).First();
selectedString = randomWord.Descendants("word").SingleOrDefault().Value.ToString();
selectedMeanings = randomWord.Descendants("meaning").SingleOrDefault().Value.ToString();
string scrambledString = ScrambleWord(selectedString);
txtQ0.Text = scrambledString.ElementAt(0).ToString();
txtQ1.Text = scrambledString.ElementAt(1).ToString();
txtQ2.Text = scrambledString.ElementAt(2).ToString();
txtQ3.Text = scrambledString.ElementAt(3).ToString();
txtQ4.Text = scrambledString.ElementAt(4).ToString();
txtQ5.Text = scrambledString.ElementAt(5).ToString();
txtQ6.Text = scrambledString.ElementAt(6).ToString();
checkSetHighScore();
//removing the node part
randomWord.Remove();
Stream stream = new MemoryStream(); // Create a stream
definitionFile.Save(stream); // Save XDocument into the stream
stream.Position = 0;
Remember this is Windows 8.1 RT (not Silverlight)
No comments:
Post a Comment