Ejemplo n.º 1
0
        private void Download()
        {
            //_release.Url = "http://malealpha.com/dwl/tinyfile.dat";
            //_release.Url = "http://malealpha.com/dwl/bigfile.dat";
            //_release.Url = "http://malealpha.com/dwl/bigfile.dats";
            try
            {
                downloader.Execute(new FileDownload()
                {
                    Url      = _release.Url,
                    Filename = System.IO.Path.Combine(txtSavePath.Text,
                                                      System.IO.Path.GetFileName(Release.Url))
                });

                if (!downloader.Abort)
                {
                    // Vérifier le hash
                    Crc32 crc = new Crc32();

                    crc.Update(File.ReadAllBytes(_setup));
                    if (crc.Value.ToString("X").CompareTo(Release.CRC) != 0)
                    {
                        throw new Exception(strings.Updater_CorruptFile);
                    }
                    NextStep();
                }
                else
                {
                    throw new Exception(strings.Updater_DownloadCancel);
                }
            }
            catch (Exception error)
            {
                txtDwlError.Text       = error.Message;
                txtDwlError.Visibility = System.Windows.Visibility.Visible;
            }
        }