I am making a small program that downloads files from internet, depending on the file version of another file.
Here is some of the code (where I am getting an error):
XmlDocument xdoc = new XmlDocument();
xdoc.Load("http://raiderz.daregamer.com/updates/app_version.xml");
XmlNodeList xNodeVer = xdoc.DocumentElement.SelectNodes("Version");
FileVersionInfo fileVer = FileVersionInfo.GetVersionInfo(AppDomain.CurrentDomain.BaseDirectory + "FileCheckVer.exe");
double ver_app = Convert.ToDouble(fileVer.FileVersion.ToString());
double ver_xml = Convert.ToDouble(xNodeVer);
The error says, “Input string was not in a correct format.” and points to the following line.
double ver_app = Convert.ToDouble(fileVer.FileVersion.ToString());
Does anyone know what the correct format is?
Thanks!
A FileVersion is in the Format d.d.d.d (2.0.0.0), where a double is just a floating point number (d.d).
All the information you need is in the FileVersionInfo instance you already created (check the properties).
/EDIT
Answer to Q2. You need to use SelectSingleNode() to return an XmlNode, then you look at the .Value property of that.