I am currently implementing a wpf application with a login system. To connect the server and call the database is slower than a file-based database, we think that xml file works fine for us.
My problem is actually the same as the problem which is stated in this topic:
When I add it to the project, it looks for it in the app root directory (WpfApplication1\WpfApplication1\myfile.xml). But then when I run the app, the function in charge to add a node works fine, but it saves the file to the WpfApplication1\WpfApplication1\bin\Debug\ directory ! Hence the "real" myfile.xml is not updated
WPF C# XML file added as resource
I tried the comment "If you want the xml to be loaded from disc (and modified), use Build Action = None and Copy = Copy Always." , but It didn't work for me.
I use System.Xml.Linq library and I try to update my XML file with this code piece:
XDocument xmlDoc = XDocument.Load("users.xml");
xmlDoc.Root.Add(
new XElement("user",
new XElement("username", this.textBox1.Text),
new XElement("password", this.textBox2.Text),
new XElement("ITAdmin", comboBox1.SelectedText == "Yes" ? 1 : 0)));
xmlDoc.Save("users.xml");
My second problem is that I've added xml file as a resource to my project, because I don't want that it is reachable from application users, but I can't update the xml file again.