HttpWebRequest web;
try
{
web = (HttpWebRequest)HttpWebRequest.Create("website.name");
WebResponse Response = web.GetResponse();
Stream WebStream = Response.GetResponseStream();
StreamReader Reader = new StreamReader(WebStream);
string data = Reader.ReadToEnd();
Reader.Close();
WebStream.Close();
Response.Close();
string[] ver = Regex.Split(data, "version=");
if (int.Parse(ver[1]) == int.Parse(appVersion))
{
tss1.Text = "Status : You currently have the latest version";
}
else
{
tss1.Text ="Status : A new version of app is available.";
System.Diagnostics.Process.Start("website.name");
}
}
catch (Exception ex)
{
tss1.Text = "Status : Update check failed.";
Debug.Write(ex.ToString());
}
我想使用上面的代碼連接到網頁,並拉下了它的應用程序的最新版本號,它只是罰款。嘗試將網頁上發現的號碼與提供的號碼進行比較時出現問題 appVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
C#整數解析/比較
你能否闡述一下你得到什麼結果還是什麼問題? – CodingGorilla 2010-09-17 18:46:03
而不是Regex.Split(data,「version =」);爲什麼不簡單data.Substring(「版本=」。長度); – 2010-09-17 20:52:58