public void DownloadPatchlog()
 {
     if (String.IsNullOrEmpty(ChangelogFileName) == false)
     {
         try
         {
             CurrentChangelog = LauncherUtility.DownloadString(ChangelogUrl);
         }
         catch (Exception e)
         {
             Program.LogException(e);
         }
     }
 }
        public virtual UpdateCheckResult CheckForUpdates()
        {
            if (String.IsNullOrEmpty(VersionFileName))
            {
                throw new InvalidOperationException("VersionFileName is not set to a value.");
            }
            if (String.IsNullOrEmpty(BaseUrl))
            {
                throw new InvalidOperationException("BaseUrl is not set to a value.");
            }

            if (ForceUpdate)
            {
                ForceUpdate        = true;
                CurrentVersionText = "Update required.";
            }

            // Force Update If File Missing
            Version currentVersion       = null;
            int     currentVersionNumber = 0;
            string  currentVersionText   = null;

            if (File.Exists(VersionFileName) == false)
            {
                ForceUpdate        = true;
                CurrentVersionText = "Version cannot be determined.";
            }
            else
            {
                currentVersionText = File.ReadAllText(VersionFileName);

                // Reading Current Version
                switch (VersionCompareMode)
                {
                case VersionCompareMode.Version:
                    currentVersion     = new Version(currentVersionText);
                    CurrentVersionText = currentVersion.ToString();
                    break;

                case VersionCompareMode.Number:
                    currentVersionNumber = Int32.Parse(currentVersionText);
                    CurrentVersionText   = currentVersionNumber.ToString();
                    break;

                case VersionCompareMode.SameText:
                    CurrentVersionText = currentVersionText;
                    break;
                }
            }

            // Getting Server Version
            string serverVersionText;

            try
            {
                //using (WebClient client = new WebClient())
                //{
                //    serverVersionText = client.DownloadString(VersionFileUrl);
                //    m_ServerVersionRawText = serverVersionText;
                //}
                serverVersionText      = LauncherUtility.DownloadString(VersionFileUrl);
                m_ServerVersionRawText = serverVersionText;
            }
            catch (WebException e)
            {
                Error = e;
                Program.LogException(e);
                if (e.Status == WebExceptionStatus.Timeout)
                {
                    CheckResult = UpdateCheckResult.Timeout;
                }
                else
                {
                    CheckResult = UpdateCheckResult.Error;
                }
                return(CheckResult);
            }
            catch (Exception e)
            {
                Error = e;
                Program.LogException(e);
                CheckResult = UpdateCheckResult.Error;
                return(CheckResult);
            }

            Version serverVersion       = null;
            int     serverVersionNumber = 0;

            switch (VersionCompareMode)
            {
            case VersionCompareMode.Version:
                serverVersion  = new Version(serverVersionText);
                NewVersionText = serverVersion.ToString();
                break;

            case VersionCompareMode.Number:
                serverVersionNumber = Int32.Parse(serverVersionText);
                NewVersionText      = serverVersionNumber.ToString();
                break;

            case VersionCompareMode.SameText:
                NewVersionText = serverVersionText;
                break;
            }

            if (ForceUpdate)
            {
                CheckResult = UpdateCheckResult.DownloadRequired;
                return(CheckResult);
            }

            // Comparing Versions
            switch (VersionCompareMode)
            {
            case VersionCompareMode.Version:
                CheckResult = (serverVersion > currentVersion) ? UpdateCheckResult.UpdateAvailable : UpdateCheckResult.NoUpdatesAvailable;
                break;

            case VersionCompareMode.Number:
                CheckResult = serverVersionNumber > currentVersionNumber ? UpdateCheckResult.UpdateAvailable : UpdateCheckResult.NoUpdatesAvailable;
                break;

            case VersionCompareMode.SameText:
                CheckResult = String.Equals(serverVersionText, currentVersionText, StringComparison.InvariantCultureIgnoreCase) == false ? UpdateCheckResult.UpdateAvailable : UpdateCheckResult.NoUpdatesAvailable;
                break;

            default:
                CheckResult = UpdateCheckResult.UpdateAvailable;
                break;
            }
            return(CheckResult);
        }