Need help parsing XML Files

Clash Royale CLAN TAG#URR8PPPNeed help parsing XML Files
Okay So I have 3 problems with my application atm:
Directory.GetFiles
So here is my code for problem #1 & #2:
public void patchxml()
{
string xmldir = AppDomain.CurrentDomain.BaseDirectory + @"\tmp";
string xmlfile = Directory.GetFiles(xmldir, "*.xml");
XDocument xdoc = XDocument.Load(xmlfile[0]);
//var element = xdoc.Elements("RequiredSystemVersion").Single(); not working
//element.Value = "0"; not working
//xdoc.Save(); not working
}
Here Is a sample of the xml file:
<?xml version="1.0" encoding="utf-8"?>
<ContentMeta>
<RequiredSystemVersion>335675392</RequiredSystemVersion>
<PatchId>0x01009bf0072d4800</PatchId>
</ContentMeta>
What I need to do is, that I need to change the required system version to 0 and then afterwards save the edited .xml. saving is also not working for me as I can't specify what file to save to, as the file path varies depending on the given input.
Also here is a sample of how I successfully managed to read from the xml:
string xmldir = AppDomain.CurrentDomain.BaseDirectory + @"\tmp";
string xmlfile = Directory.GetFiles(xmldir, "*.xml");
XDocument xdoc = XDocument.Load(xmlfile[0]);
foreach (var order in xdoc.Descendants("ContentMeta"))
{
string mrmk = order.Element("Min").Value;
{
keylabel.Content = mrmk;
}
}
if (keylabel.Content.Equals("4"))
{
fwlabel.Content = "4.0.0";
}
ToString()
For #3 you might want to look at Escape command line arguments in c# and C# Launch application with multiple arguments or Pass string list as parameter to console application. But really #3 needs to be broken into a separate question that shows exactly what you need to do and have tried so far.
– dbc
15 mins ago
I updated the OP to your wish, and I do hope that it is better understandable now
– adrifcastr
9 mins ago
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Firstly, please try to break your post into multiple questions. See Can I ask only one question per post? for which the answer is yes. Secondly, for each question, can you try to provide a Minimal, Complete, and Verifiable example showing what you are doing now that doesn't work? For instance, if your code to edit XML is not working, we're more likely to be able to help if you share the (simplified) XML as well as the code. Thirdly, if something is "not working" can you share details if what does happen? E.g. if an exception, please share the full
ToString()output.– dbc
25 mins ago