Пример #1
0
        // a user clicked the link..
        void SimpleLinkLabel_Click(object sender, EventArgs e)
        {
            try
            {
                if (!UseDownloadDialogOnBinaries)
                {
                    System.Diagnostics.Process.Start(LinkUrl);
                }
                else
                {
                    if (VersionCheck.AboutDialogDisplayDownloadDialog)
                    {
                        if (Uri.IsWellFormedUriString(LinkUrl, UriKind.Absolute))
                        {
                            FormCheckVersion.CheckForNewVersion(VersionCheck.CheckUri,
                                                                AboutAssembly == null ? Assembly.GetEntryAssembly() : AboutAssembly,
                                                                CultureInfo.CurrentCulture.Name);
                        }
                        return;
                    }

                    if (VersionCheck.DownloadFile(LinkUrl, TempPath))
                    {
                        VersionCheck.IncreaseDownloadCount(SoftwareName);

                        var processCommand = Path.Combine(TempPath, Path.GetFileName(new Uri(LinkUrl).LocalPath));
                        if (Path.GetExtension(processCommand)
                            ?.Equals(".msi", StringComparison.InvariantCultureIgnoreCase) == true)
                        {
                            System.Diagnostics.Process.Start(new ProcessStartInfo(processCommand)
                            {
                                UseShellExecute = true
                            });
                        }
                        else
                        {
                            System.Diagnostics.Process.Start(processCommand);
                        }
                    }
                    else
                    {
                        try
                        {
                            File.Delete(Path.Combine(TempPath, Path.GetFileName(new Uri(LinkUrl).LocalPath)));
                        }
                        catch
                        {
                            // ignored..
                        }
                    }
                }
            }
            catch
            {
                // ignored..
            }
        }