Example #1
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            Text = Resources.WindowTitle;
            TaskBar.Progress.SetState(Handle, TaskBar.Progress.Flags.Indeterminate);
            if (!NetEx.InternetIsAvailable())
            {
                if (!_silent || !File.Exists(_appPath))
                {
                    MessageBoxEx.Show(Resources.Msg_Err_00, Resources.WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                Application.Exit();
                return;
            }
            string updUrl = null;

            try
            {
                var source = NetEx.Transfer.DownloadString(Resources.RegexFirstUrl);
                if (string.IsNullOrWhiteSpace(source))
                {
                    throw new ArgumentNullException(nameof(source));
                }
                source = TextEx.FormatNewLine(source).SplitNewLine().SkipWhile(x => !x.ContainsEx(Resources.RegexSecBtnMatch)).Take(1).Join();
                foreach (Match match in Regex.Matches(source, Resources.RegexSecUrlPattern, RegexOptions.Singleline))
                {
                    var mUrl = match.Groups[1].ToString();
                    if (string.IsNullOrWhiteSpace(mUrl))
                    {
                        continue;
                    }
                    source = NetEx.Transfer.DownloadString(mUrl);
                    if (string.IsNullOrWhiteSpace(source))
                    {
                        throw new ArgumentNullException(nameof(source));
                    }
                    source = TextEx.FormatNewLine(source).SplitNewLine().SkipWhile(x => !x.ContainsEx(Resources.RegexThirdBtnMatch) || !Resources.RegexThirdExtMatch.SplitNewLine().Any(y => x.ContainsEx(y))).Take(1).Join();
                    foreach (Match match2 in Regex.Matches(source, Resources.RegexThirdUrlPattern, RegexOptions.Singleline))
                    {
                        mUrl = match2.Groups[1].ToString();
                        if (string.IsNullOrWhiteSpace(mUrl))
                        {
                            continue;
                        }
                        if (mUrl.ContainsEx("/show/"))
                        {
                            mUrl = mUrl.Replace("/show/", "/get/");
                        }
                        updUrl = mUrl;
                        break;
                    }
                    break;
                }
                if (!NetEx.FileIsAvailable(updUrl, 60000, Resources.UserAgent))
                {
                    throw new PathNotFoundException(updUrl);
                }
            }
            catch (Exception ex)
            {
                Log.Write(ex);
                if (!_silent || !File.Exists(_appPath))
                {
                    MessageBoxEx.Show(Resources.Msg_Warn_01, Resources.WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                Application.Exit();
                return;
            }
            var localDate  = File.GetLastWriteTime(_appPath);
            var onlineDate = NetEx.GetFileDate(updUrl, Resources.UserAgent);

            if ((onlineDate - localDate).Days > 0)
            {
                if (_silent || MessageBoxEx.Show(Resources.Msg_Hint_00, Resources.WindowTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    var archivePath = PathEx.Combine(PathEx.LocalDir, $"..\\{PathEx.GetTempFileName()}");
                    if (!File.Exists(archivePath))
                    {
                        _tmpDir = PathEx.Combine(Path.GetTempPath(), PathEx.GetTempDirName(Resources.AppName));
                        var hlpPath = Path.Combine(_tmpDir, "iu.zip");
                        ResourcesEx.Extract(Resources.iu, hlpPath, true);
                        Compaction.Unzip(hlpPath, _tmpDir);
                        _transfer.DownloadFile(updUrl, archivePath);
                        Opacity = 1f;
                        CheckDownload.Enabled = true;
                        return;
                    }
                    ExtractDownload.RunWorkerAsync();
                }
                Application.Exit();
                return;
            }
            if (!_silent)
            {
                MessageBoxEx.Show(Resources.Msg_Hint_01, Resources.WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            Application.Exit();
        }
Example #2
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            Text = Resources.WindowTitle;
            TaskBar.Progress.SetState(Handle, TaskBar.Progress.Flags.Indeterminate);
            if (!NetEx.InternetIsAvailable())
            {
                if (!_silent || !File.Exists(_appPath))
                {
                    MessageBoxEx.Show(Resources.Msg_Err_00, Resources.WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                Application.Exit();
                return;
            }
            string updUrl = null;

            try
            {
                var regexUrl = Resources.RegexUrl;
                if (!Ini.ReadDirect("Settings", "BetaUpdates").EqualsEx("1", "True"))
                {
                    regexUrl += "/latest";
                }
                var source = NetEx.Transfer.DownloadString(regexUrl);
                if (string.IsNullOrWhiteSpace(source))
                {
                    throw new ArgumentNullException(nameof(source));
                }
                source = TextEx.FormatNewLine(source);
#if x86
                const string arch = "32";
#else
                const string arch = "64";
#endif
                source = source.SplitNewLine().Where(x => x.ContainsEx(Resources.SearchPrefix) && x.ContainsEx(string.Format(Resources.SearchSuffix, arch))).Take(1).Join();
                foreach (Match match in Regex.Matches(source, Resources.RegexPattern, RegexOptions.Singleline))
                {
                    var mPath = match.Groups[1].ToString();
                    if (string.IsNullOrWhiteSpace(mPath) || mPath.Count(c => c == '/') != 1)
                    {
                        continue;
                    }
                    updUrl = string.Format(Resources.UpdateUrl, mPath);
                    break;
                }
                if (!NetEx.FileIsAvailable(updUrl, 60000, Resources.UserAgent))
                {
                    throw new PathNotFoundException(updUrl);
                }
            }
            catch (Exception ex)
            {
                Log.Write(ex);
                if (!_silent || !File.Exists(_appPath))
                {
                    MessageBoxEx.Show(Resources.Msg_Warn_01, Resources.WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                Application.Exit();
            }
            var localDate  = File.GetLastWriteTime(_appPath);
            var onlineDate = NetEx.GetFileDate(updUrl, Resources.UserAgent);
            if ((onlineDate - localDate).Days > 0)
            {
                if (_silent || MessageBoxEx.Show(Resources.Msg_Hint_00, Resources.WindowTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    var archivePath = PathEx.Combine(PathEx.LocalDir, $"..\\{PathEx.GetTempFileName()}");
                    if (!File.Exists(archivePath))
                    {
                        _tmpDir = PathEx.Combine(Path.GetTempPath(), PathEx.GetTempDirName(Resources.AppName));
                        var hlpPath = Path.Combine(_tmpDir, "7z.zip");
                        ResourcesEx.Extract(Resources._7z, hlpPath, true);
                        Compaction.Unzip(hlpPath, _tmpDir);
                        _transfer.DownloadFile(updUrl, archivePath);
                        Opacity = 1f;
                        CheckDownload.Enabled = true;
                        return;
                    }
                    ExtractDownload.RunWorkerAsync();
                }
                Application.Exit();
                return;
            }
            if (!_silent)
            {
                MessageBoxEx.Show(Resources.Msg_Hint_01, Resources.WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            Application.Exit();
        }
Example #3
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            Text = Resources.WindowTitle;
            TaskBar.Progress.SetState(Handle, TaskBar.Progress.Flags.Indeterminate);
            if (!NetEx.InternetIsAvailable())
            {
                if (!_silent || !File.Exists(_appPath))
                {
                    MessageBoxEx.Show(Resources.Msg_Err_00, Resources.WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                Application.Exit();
                return;
            }
            string updUrl;

            try
            {
                updUrl = string.Format(Resources.UpdateUrl,
#if x86
                                       "x86"
#else
                                       "x64"
#endif
                                       );
                if (!NetEx.FileIsAvailable(updUrl, 60000, Resources.UserAgent))
                {
                    throw new PathNotFoundException(updUrl);
                }
            }
            catch (Exception ex)
            {
                Log.Write(ex);
                if (!_silent || !File.Exists(_appPath))
                {
                    MessageBoxEx.Show(Resources.Msg_Warn_01, Resources.WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                Application.Exit();
                return;
            }
            var appPath    = PathEx.Combine(Resources.AppPath);
            var localDate  = File.GetLastWriteTime(appPath);
            var onlineDate = NetEx.GetFileDate(updUrl, Resources.UserAgent);
            if ((onlineDate - localDate).Days > 0)
            {
                if (_silent || MessageBoxEx.Show(Resources.Msg_Hint_00, Resources.WindowTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    var archivePath = PathEx.Combine(PathEx.LocalDir, $"..\\{PathEx.GetTempFileName()}");
                    if (!File.Exists(archivePath))
                    {
                        _tmpDir = PathEx.Combine(Path.GetTempPath(), PathEx.GetTempDirName(Resources.AppName));
                        var hlpPath = Path.Combine(_tmpDir, "iu.zip");
                        ResourcesEx.Extract(Resources.iu, hlpPath, true);
                        Compaction.Unzip(hlpPath, _tmpDir);
                        _transfer.DownloadFile(updUrl, archivePath);
                        Opacity = 1f;
                        CheckDownload.Enabled = true;
                        return;
                    }
                    ExtractDownload.RunWorkerAsync();
                }
                Application.Exit();
                return;
            }
            if (!_silent)
            {
                MessageBoxEx.Show(Resources.Msg_Hint_01, Resources.WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            Application.Exit();
        }
Example #4
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            Text = Resources.WindowTitle;
            TaskBar.Progress.SetState(Handle, TaskBar.Progress.Flags.Indeterminate);
            if (!NetEx.InternetIsAvailable())
            {
                if (!_silent || !File.Exists(_appPath))
                {
                    MessageBoxEx.Show(Resources.Msg_Err_00, Resources.WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                Application.Exit();
                return;
            }
            string updUrl;

            try
            {
                var mirrors   = Resources.UpdateMirrors.SplitNewLine();
                var mirrorMap = new Dictionary <long, string>();
                foreach (var url in mirrors)
                {
                    var ping = NetEx.Ping(url);
                    while (mirrorMap.ContainsKey(ping))
                    {
                        ping++;
                    }
                    mirrorMap.Add(ping, url);
                }
                var sortedPings = mirrorMap.Keys.ToList();
                sortedPings.Sort();
                var bestPing = sortedPings.Min();
                var mirror   = mirrorMap[bestPing];
                var source   = NetEx.Transfer.DownloadString(string.Format(Resources.RegexUrl, mirror));
                if (string.IsNullOrWhiteSpace(source))
                {
                    foreach (var ping in sortedPings)
                    {
                        source = NetEx.Transfer.DownloadString(string.Format(Resources.RegexUrl, ping));
                        break;
                    }
                }
                if (string.IsNullOrWhiteSpace(source))
                {
                    throw new ArgumentNullException(nameof(source));
                }
                var vers = new List <Version>();
                foreach (Match match in Regex.Matches(source, Resources.RegexVersionPattern, RegexOptions.Singleline))
                {
                    var mVer = match.Groups[1].ToString();
                    if (string.IsNullOrWhiteSpace(mVer))
                    {
                        continue;
                    }
                    var cVer = mVer.ToCharArray();
                    if (!cVer.Count(char.IsDigit).IsBetween(3, 16) || !cVer.Count(c => c == '.').IsBetween(2, 3))
                    {
                        continue;
                    }
                    mVer = new string(mVer.Where(c => char.IsDigit(c) || c == '.').ToArray());
                    if (!Version.TryParse(mVer, out Version ver))
                    {
                        continue;
                    }
                    vers.Add(ver);
                }
                _ver   = vers.Max();
                updUrl = string.Format(Resources.UpdateUrl, mirror, _ver,
#if x86
                                       "32"
#else
                                       "64"
#endif
                                       );
                var exists = NetEx.FileIsAvailable(updUrl, 60000, Resources.UserAgent);
                if (!exists)
                {
                    foreach (var ping in sortedPings)
                    {
                        updUrl = string.Format(Resources.UpdateUrl, mirrorMap[ping], _ver,
#if x86
                                               "32"
#else
                                               "64"
#endif
                                               );
                        exists = NetEx.FileIsAvailable(updUrl, 60000, Resources.UserAgent);
                        if (exists)
                        {
                            break;
                        }
                    }
                }
                if (!exists)
                {
                    throw new PathNotFoundException(updUrl);
                }
            }
            catch (Exception ex)
            {
                Log.Write(ex);
                if (!_silent || !File.Exists(_appPath))
                {
                    MessageBoxEx.Show(Resources.Msg_Warn_01, Resources.WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                Application.Exit();
                return;
            }
            var localDate  = File.GetLastWriteTime(_appPath);
            var onlineDate = NetEx.GetFileDate(updUrl, Resources.UserAgent);
            if ((onlineDate - localDate).Days > 0)
            {
                if (_silent || MessageBoxEx.Show(Resources.Msg_Hint_00, Resources.WindowTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    var archivePath = PathEx.Combine(PathEx.LocalDir, $"..\\{PathEx.GetTempFileName()}");
                    if (!File.Exists(archivePath))
                    {
                        _tmpDir = PathEx.Combine(Path.GetTempPath(), PathEx.GetTempDirName(Resources.AppName));
                        var hlpPath = Path.Combine(_tmpDir, "7z.zip");
                        ResourcesEx.Extract(Resources._7z, hlpPath, true);
                        Compaction.Unzip(hlpPath, _tmpDir);
                        _transfer.DownloadFile(updUrl, archivePath);
                        Opacity = 1f;
                        CheckDownload.Enabled = true;
                        return;
                    }
                    ExtractDownload.RunWorkerAsync();
                }
                Application.Exit();
                return;
            }
            if (!_silent)
            {
                MessageBoxEx.Show(Resources.Msg_Hint_01, Resources.WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            Application.Exit();
        }
Example #5
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            Text = Resources.WindowTitle;
            TaskBar.Progress.SetState(Handle, TaskBar.Progress.Flags.Indeterminate);
            if (!NetEx.InternetIsAvailable())
            {
                if (!_silent || !File.Exists(_appPath))
                {
                    MessageBoxEx.Show(Resources.Msg_Err_00, Resources.WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                Application.Exit();
                return;
            }
            string updUrl = null;

            try
            {
                var source = NetEx.Transfer.DownloadString(Resources.RegexUrl);
                if (string.IsNullOrWhiteSpace(source))
                {
                    throw new ArgumentNullException(nameof(source));
                }
                var paths = new Dictionary <Version, string>();
                foreach (Match match in Regex.Matches(source, Resources.RegexPattern, RegexOptions.Singleline))
                {
                    var mPath = match.Groups[1].ToString();
                    if (string.IsNullOrWhiteSpace(mPath) || mPath.Count(c => c == '/') != 1)
                    {
                        continue;
                    }
                    var mVer = mPath.Split('/').FirstOrDefault();
                    if (string.IsNullOrEmpty(mVer) || !mVer.All(c => char.IsDigit(c) || c == '.'))
                    {
                        continue;
                    }
                    if (!Version.TryParse(mVer, out Version ver) || paths.ContainsKey(ver))
                    {
                        continue;
                    }
                    paths.Add(ver, mPath);
                }
                updUrl = string.Format(Resources.UpdateUrl, paths[paths.Keys.Max()]);
                if (!NetEx.FileIsAvailable(updUrl, 60000, Resources.UserAgent))
                {
                    throw new PathNotFoundException(updUrl);
                }
            }
            catch (Exception ex)
            {
                Log.Write(ex);
                if (!_silent || !File.Exists(_appPath))
                {
                    MessageBoxEx.Show(Resources.Msg_Warn_01, Resources.WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                Application.Exit();
            }
            var localDate  = File.GetLastWriteTime(_appPath);
            var onlineDate = NetEx.GetFileDate(updUrl, Resources.UserAgent);

            if ((onlineDate - localDate).Days > 0)
            {
                if (_silent || MessageBoxEx.Show(Resources.Msg_Hint_00, Resources.WindowTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    var archivePath = PathEx.Combine(PathEx.LocalDir, $"..\\{PathEx.GetTempFileName()}");
                    if (!File.Exists(archivePath))
                    {
                        _tmpDir = PathEx.Combine(Path.GetTempPath(), PathEx.GetTempDirName(Resources.AppName));
                        var hlpPath = Path.Combine(_tmpDir, "iu.zip");
                        ResourcesEx.Extract(Resources.iu, hlpPath, true);
                        Compaction.Unzip(hlpPath, _tmpDir);
                        _transfer.DownloadFile(updUrl, archivePath);
                        Opacity = 1f;
                        CheckDownload.Enabled = true;
                        return;
                    }
                    ExtractDownload.RunWorkerAsync();
                }
                Application.Exit();
                return;
            }
            if (!_silent)
            {
                MessageBoxEx.Show(Resources.Msg_Hint_01, Resources.WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            Application.Exit();
        }
Example #6
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            Text = Resources.WindowTitle;
            TaskBar.Progress.SetState(Handle, TaskBar.Progress.Flags.Indeterminate);
            if (!NetEx.InternetIsAvailable())
            {
                if (!_silent || !File.Exists(_appPath))
                {
                    MessageBoxEx.Show(Resources.Msg_Err_00, Resources.WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                Application.Exit();
                return;
            }
            var iniFile = Path.ChangeExtension(PathEx.LocalPath, ".ini");

            if (!File.Exists(iniFile))
            {
                Ini.SetFile(iniFile);
                Ini.Write("Settings", "Language", "English");
                Ini.Write("Settings", "Architecture", Environment.Is64BitProcess ? "64 bit" : "32 bit");
                Ini.Write("Settings", "DoNotAskAgain", false);
            }
            else
            {
                Ini.SetFile(iniFile);
            }
            if (!Ini.Read("Settings", "DoNotAskAgain", false))
            {
                Form langSelection = new LangSelectionForm();
                if (langSelection.ShowDialog() != DialogResult.OK)
                {
                    MessageBoxEx.Show(Resources.Msg_Hint_03, Resources.WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Application.Exit();
                    return;
                }
            }
            var    lang   = $"{Ini.Read<string>("Settings", "Language", "English")} ({Ini.Read<string>("Settings", "Architecture", Environment.Is64BitProcess ? "64 bit" : "32 bit")})";
            var    source = NetEx.Transfer.DownloadString(Resources.RegexUrl);
            string updUrl = null;

            try
            {
                foreach (Match match in Regex.Matches(source, Resources.RegexLinePattern, RegexOptions.Singleline))
                {
                    var mLine = match.Groups[1].ToString();
                    var mLang = Regex.Match(mLine, Resources.RegexLanguagePattern, RegexOptions.Singleline).Groups[1].ToString();
                    if (string.IsNullOrWhiteSpace(mLang) || !mLang.EqualsEx(lang))
                    {
                        continue;
                    }
                    var mVer = Regex.Match(mLine, Resources.RegexVersionPattern, RegexOptions.Singleline).Groups[1].ToString();
                    if (string.IsNullOrWhiteSpace(mVer) || mVer.ContainsEx("trial", "free", "beta"))
                    {
                        continue;
                    }
                    var mName = Regex.Match(mLine, Resources.RegexFileNamePattern, RegexOptions.Singleline).Groups[1].ToString();
                    if (string.IsNullOrWhiteSpace(mName))
                    {
                        continue;
                    }
                    updUrl = string.Format(Resources.UpdateUrl, mName);
                    if (!NetEx.FileIsAvailable(updUrl, 60000, Resources.UserAgent))
                    {
                        updUrl = null;
                        continue;
                    }
                    break;
                }
                if (string.IsNullOrEmpty(updUrl))
                {
                    throw new ArgumentNullException(nameof(updUrl));
                }
            }
            catch (Exception ex)
            {
                Log.Write(ex);
                if (!_silent || !File.Exists(_appPath))
                {
                    MessageBoxEx.Show(Resources.Msg_Warn_02, Resources.WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                Application.Exit();
                return;
            }
            var localDate  = File.GetLastWriteTime(_appPath);
            var onlineDate = NetEx.GetFileDate(updUrl, Resources.UserAgent);

            if ((onlineDate - localDate).Days > 0)
            {
                if (_silent || MessageBoxEx.Show(Resources.Msg_Hint_00, Resources.WindowTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    var archivePath = PathEx.Combine(PathEx.LocalDir, $"..\\{PathEx.GetTempFileName()}");
                    if (!File.Exists(archivePath))
                    {
                        _tmpDir = PathEx.Combine(Path.GetTempPath(), PathEx.GetTempDirName(Resources.AppName));
                        var hlpPath = Path.Combine(_tmpDir, "7z.zip");
                        ResourcesEx.Extract(Resources._7z, hlpPath, true);
                        Compaction.Unzip(hlpPath, _tmpDir);
                        _transfer.DownloadFile(updUrl, archivePath);
                        Opacity = 1f;
                        CheckDownload.Enabled = true;
                        return;
                    }
                    ExtractDownload.RunWorkerAsync();
                }
                Application.Exit();
                return;
            }
            if (!_silent)
            {
                MessageBoxEx.Show(Resources.Msg_Hint_01, Resources.WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            Application.Exit();
        }
Example #7
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            Text = Resources.WindowTitle;
            TaskBar.Progress.SetState(Handle, TaskBar.Progress.Flags.Indeterminate);
            if (!NetEx.InternetIsAvailable())
            {
                if (!_silent || !File.Exists(_appPath))
                {
                    MessageBoxEx.Show(Resources.Msg_Err_00, Resources.WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                Application.Exit();
                return;
            }
            string updUrl = null;

            try
            {
                _tmpDir = PathEx.Combine(Path.GetTempPath(), PathEx.GetTempDirName(Resources.AppDisplayName));
                var hlpPath = Path.Combine(_tmpDir, "js.zip");
                ResourcesEx.Extract(Resources.js, hlpPath, true);
                Compaction.Unzip(hlpPath, _tmpDir);
                Thread.Sleep(200);
                var helperPath = Path.Combine(_tmpDir, "read.js");
                var source     = Path.Combine(_tmpDir, "source.txt");
                File.WriteAllText(helperPath, Resources.JsScript);
                using (var p = ProcessEx.Send(string.Format(Resources.RunScript, _tmpDir), Elevation.IsAdministrator, ProcessWindowStyle.Hidden, false))
                    if (p?.HasExited == false)
                    {
                        p.WaitForExit();
                    }
                source = File.ReadAllText(source);
                if (string.IsNullOrWhiteSpace(source))
                {
                    throw new ArgumentNullException(nameof(source));
                }
                source = TextEx.FormatNewLine(source).SplitNewLine().SkipWhile(x => !x.ContainsEx(".exe")).Take(1).Join();
                foreach (Match match in Regex.Matches(source, Resources.RegexUrlPattern, RegexOptions.Singleline))
                {
                    var mUrl = match.Groups[1].ToString();
                    if (string.IsNullOrWhiteSpace(mUrl))
                    {
                        continue;
                    }
                    updUrl = mUrl.Trim('"');
                    break;
                }
                if (!NetEx.FileIsAvailable(updUrl, 60000, Resources.UserAgent))
                {
                    throw new PathNotFoundException(updUrl);
                }
            }
            catch (Exception ex)
            {
                Log.Write(ex);
                if (!_silent || !File.Exists(_appPath))
                {
                    MessageBoxEx.Show(Resources.Msg_Warn_01, Resources.WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                Application.Exit();
                return;
            }
            var localDate  = File.GetLastWriteTime(_appPath);
            var onlineDate = NetEx.GetFileDate(updUrl, Resources.UserAgent);

            if ((onlineDate - localDate).Days > 0)
            {
                if (_silent || MessageBoxEx.Show(Resources.Msg_Hint_00, Resources.WindowTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    var archivePath = PathEx.Combine(PathEx.LocalDir, $"..\\{PathEx.GetTempFileName()}");
                    if (!File.Exists(archivePath))
                    {
                        var hlpPath = Path.Combine(_tmpDir, "iu.zip");
                        ResourcesEx.Extract(Resources.iu, hlpPath, true);
                        Compaction.Unzip(hlpPath, _tmpDir);
                        _transfer.DownloadFile(updUrl, archivePath);
                        Opacity = 1f;
                        CheckDownload.Enabled = true;
                        return;
                    }
                    ExtractDownload.RunWorkerAsync();
                }
                Application.Exit();
                return;
            }
            if (!_silent)
            {
                MessageBoxEx.Show(Resources.Msg_Hint_01, Resources.WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            Application.Exit();
        }