user11405709
user11405709

Reputation: 1

Increasing a version between a XML Tag

I have made a application to update my other applications. I am using autoupdater.net library to handle the updates. My question is how can I get the version of one application from another?

<?xml version="1.0" encoding="UTF-8"?>
<item>
    <version>1.0.1.0</version> // I would like to update this with the assembly version of another application
    <url></url>
    <changelog></changelog>
    <mandatory mode="2">true</mandatory>
</item>

What this application does is deletes the current zip, zips up the release folder and then the last step would be updating this xml document with the new version number.

Upvotes: 2

Views: 340

Answers (1)

NoConnection
NoConnection

Reputation: 842

This should work:

XmlDocument doc = new XmlDocument();
doc.Load(@"filepath");

var versionNode = doc.SelectSingleNode("item/version");
versionNode.InnerText = Assembly.GetExecutingAssembly().GetName().Version.ToString();
doc.Save(@"filepath");

You can also load the xml from a string directly if you don't have a file on your disk. Also this gets the version string of the executing assembly. Replace this with the version number if needed.

Upvotes: 3

Related Questions