Beispiel #1
0
        public static Version GetRemoteVersion()
        {
            Version ver        = new Version(0, 0, 0, 0);
            string  urlAddress = "";

#if DEBUG
            urlAddress = "https://raw.githubusercontent.com/hipa-org/HIPA-GUI/dev/HIPA/Properties/AssemblyInfo.cs";
#else
            urlAddress = "https://raw.githubusercontent.com/hipa-org/HIPA-GUI/master/HIPA/Properties/AssemblyInfo.cs";
#endif

            HttpWebRequest  request  = (HttpWebRequest)WebRequest.Create(urlAddress);
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();

            if (response.StatusCode == HttpStatusCode.OK)
            {
                Stream       receiveStream = response.GetResponseStream();
                StreamReader readStream    = null;

                if (response.CharacterSet == null)
                {
                    readStream = new StreamReader(receiveStream);
                }
                else
                {
                    readStream = new StreamReader(receiveStream, Encoding.GetEncoding(response.CharacterSet));
                }


                string data = readStream.ReadToEnd();
                response.Close();
                readStream.Close();

                Version.TryParse(MiscHandler.GetStringBetween(data, "AssemblyFileVersion(\"", "\")"), out ver);
            }
            return(ver);
        }