通过文本文件检查应用程序版本

时间:2013-07-15 03:14:56

标签: c#

我需要帮助,这不会给我任何错误,但它也不起作用:/

如果有人可以提供帮助,我会很感激。

WebRequest request = WebRequest.Create("http://sitebuilder.yola.com/restricted_view/site_design/8a4986ca3fa8df50013fb4a713810fe3/resources/program_hudtool/version_hudtool.txt");
WebResponse response = request.GetResponse();
System.IO.StreamReader sr = new System.IO.StreamReader(response.GetResponseStream());
string newestversion = sr.ReadToEnd();
string currentversion = Application.ProductVersion;

if (newestversion.Contains(currentversion))
{
this.Text = "Test [Version 0.5] | No Update Available";
}
else
{
this.Text = "Test [Version 0.5] | Update Available: " + sr.ReadToEnd();
}

1 个答案:

答案 0 :(得分:0)

首先确保从两端(网络和本地)获得正确的版本。

string newestversion = sr.ReadToEnd();
string currentversion = Application.ProductVersion;

//Test if both versions are valid.
//Debug.WriteLine(newestversion );
//Debug.WriteLine(currentversion );

Version vOnline=new Version(newestversion)
Version vLocal=new Version(currentversion )

if(vOnline > vLocal)
{
}
else
{
}