コード例 #1
0
        private static void CheckVersion(Structs.File file)
        {
            const string vZero = "0.0.0";

            //Assign version
            file.ver = File.Exists(file.fullPath) ? FileVersionInfo.GetVersionInfo(file.fullPath).FileVersion : vZero;

            if (file.title != Structs.Downloads.APP.title)
            {
                file.expectedVer = GetStringFromUrl(file.verUrl);
            }
            else
            {
                file.expectedVer = Regex.Replace(GetStringFromUrl(file.verUrl), @"\t|\n|\r", "");
            }

            string
                fileVer = String.Join("", file.ver.Split('.')),
                expVer  = String.Join("", file.expectedVer.Split('.'));

            int
                num_fileVer = int.Parse(fileVer),
                num_expVer  = int.Parse(expVer);

            if (num_fileVer < num_expVer)
            {
                if (file.title == appName + ".exe")
                {
                    isUpdated = true;
                }
                Download(file);
            }
        }
コード例 #2
0
        public static void Download(Structs.File file, bool checkExists = false)
        {
            if (checkExists && File.Exists(file.fullPath))
            {
                return;
            }
            WebClient Client = new WebClient();

            try
            {
                bool         hasVer = (!string.IsNullOrEmpty(file.expectedVer));
                string       msg    = hasVer ? "Downloading " + file.title + "\n v." + file.ver + " -> v." + file.expectedVer : "Downloading " + file.title + ".";
                DialogResult result = MessageBox.Show(new NativeWindow(), msg, "Downloading...", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                if (result == DialogResult.OK)
                {
                    Client.DownloadFile(file.downloadUrl, file.fullPath);
                }
                else
                {
                    Process.GetCurrentProcess().Kill();
                }
            }
            catch (WebException)
            {
                MessageBox.Show("Error downloading " + file.title + ".", "Download Error");
                Process.GetCurrentProcess().Kill();
            }
        }
コード例 #3
0
        public static void CheckUpdate()
        {
            //Check Versions
            Structs.File API_DLL = Structs.Downloads.API_DLL;
            Structs.File MMO_DLL = Structs.Downloads.MMO_DLL;
            Structs.File APP     = Structs.Downloads.APP;

            CheckVersion(API_DLL);
            CheckVersion(MMO_DLL);
            CheckVersion(APP);
        }