Esempio n. 1
0
        private void downloadfile(XMLreader xMLreader)
        {
            wc = new WebClient();
            wc.DownloadProgressChanged += new DownloadProgressChangedEventHandler(Wc_DownloadProgressChanged);
            wc.DownloadFileCompleted   += new AsyncCompletedEventHandler(Wc_DownloadFileCompleted);

            background                     = new BackgroundWorker();
            background.DoWork             += new DoWorkEventHandler(Background_DoWork);
            background.RunWorkerCompleted += new RunWorkerCompletedEventHandler(Background_RunWorkerCompleted);

            tempfile = Path.GetTempFileName();
            md5      = xMLreader.MD5;

            try { wc.DownloadFileAsync(new Uri(FileConfig.config.updateapi + @"/" + xMLreader.Uri), tempfile); }
            catch { this.DialogResult = DialogResult.No; this.Close(); }
        }
Esempio n. 2
0
        public static void checkversion()
        {
            try
            {
                Uri uri = new Uri(FileConfig.config.updateapi + "/update.xml");
                List <XMLreader>        xmlreader = XMLreader.Parse(uri);
                List <LocalSystemCheck> local     = LocalSystemCheck.getListFile();

                ready  = new List <XMLreader>();
                delete = new List <LocalSystemCheck>();

                foreach (XMLreader xml in xmlreader)
                {
                    if (!local.Select(o => o.filepath).ToList().Contains(xml.FilePath))
                    {
                        ready.Add(xml);
                        continue;
                    }
                    foreach (LocalSystemCheck lc in local)
                    {
                        if (lc.filepath == xml.FilePath)
                        {
                            if (lc.version < xml.Version)
                            {
                                ready.Add(xml);
                                break;
                            }
                            else if (lc.version == new Version("0.0.0.0"))
                            {
                                if (new FileInfo(lc.filepath).Length != xml.Size)
                                {
                                    ready.Add(xml);
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }