C# 软件检查软件版本

作者 by Tokeii / 2020-03-25 / 1 评论 / 2363 个足迹

        public void CheckVersion(int b)//软件启动自动检查版本
    {

        if (b==1)
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(UpdateUrl);
            Stream oStream = request.GetResponse().GetResponseStream();
            using (StreamReader respStreamReader = new StreamReader(oStream, Encoding.UTF8))
            {
                string line = string.Empty;
                line = respStreamReader.ReadLine();
                UTF8Encoding uTF8 = new UTF8Encoding(false);
                NetVersion = line;
                if (NowVersion != NetVersion)
                {
                    MessageBox.Show("需要更新\n"+"软件当前版本为:v" + NowVersion + "\n" + "软件最新版本为:v" + NetVersion);
                    AutoUpdate from = new AutoUpdate();
                    from.ShowDialog();
                }
            }
        }
        else if(b==0)
        {
            NowVersion = NetVersion;
            if (NowVersion == NetVersion)
            {
                MessageBox.Show("需要更新\n" + "软件当前版本为:v" + NowVersion + "\n" + "软件最新版本为:v" + NetVersion);
            }
        }
    }

独特见解

 评论 1 条
    • 1

      2021-07-26 09:46

       

      555