/// <summary>
        /// Downloads the game manifest.
        /// </summary>
        private void DownloadGameManifest()
        {
            try
            {
                string RemoteURL    = manifestHandler.GetGameManifestURL();
                string LocalPath    = ManifestHandler.GetGameManifestPath();
                string OldLocalPath = ManifestHandler.GetOldGameManifestPath();

                if (File.Exists(ManifestHandler.GetGameManifestPath()))
                {
                    // Create a backup of the old manifest so that we can compare them when updating the game
                    if (File.Exists(OldLocalPath))
                    {
                        File.Delete(OldLocalPath);
                    }

                    File.Move(LocalPath, OldLocalPath);
                }

                DownloadRemoteFile(RemoteURL, LocalPath);
            }
            catch (IOException ioex)
            {
                Console.WriteLine("IOException in DownloadGameManifest(): " + ioex.Message);
            }
        }
        /// <summary>
        /// Downloads the manifest for the specified module, and backs up the old copy of the manifest.
        /// </summary>
        /// <exception cref="ArgumentOutOfRangeException">
        /// Will be thrown if the <see cref="EModule"/> passed to the function is not a valid value.
        /// </exception>
        protected virtual void DownloadModuleManifest(EModule module)
        {
            string remoteURL;
            string localPath;
            string oldLocalPath;

            switch (module)
            {
            case EModule.Launcher:
            {
                remoteURL    = ManifestHandler.GetLaunchpadManifestURL();
                localPath    = ManifestHandler.GetLaunchpadManifestPath();
                oldLocalPath = ManifestHandler.GetOldLaunchpadManifestPath();

                break;
            }

            case EModule.Game:
            {
                remoteURL    = FileManifestHandler.GetGameManifestURL();
                localPath    = ManifestHandler.GetGameManifestPath();
                oldLocalPath = ManifestHandler.GetOldGameManifestPath();

                break;
            }

            default:
            {
                throw new ArgumentOutOfRangeException(nameof(module), module,
                                                      "An invalid module value was passed to DownloadModuleManifest");
            }
            }

            try
            {
                // Delete the old backup (if there is one)
                if (File.Exists(oldLocalPath))
                {
                    File.Delete(oldLocalPath);
                }

                // Create a backup of the old manifest so that we can compare them when updating the game
                File.Move(localPath, oldLocalPath);
            }
            catch (IOException ioex)
            {
                Log.Warn("Failed to back up the old launcher manifest (IOException): " + ioex.Message);
            }

            DownloadRemoteFile(remoteURL, localPath);
        }
 /// <summary>
 /// Refreshs the local copy of the launchpad manifest.
 /// </summary>
 private void RefreshGameManifest()
 {
     if (File.Exists(ManifestHandler.GetGameManifestPath()))
     {
         if (IsGameManifestOutdated())
         {
             DownloadGameManifest();
         }
     }
     else
     {
         DownloadGameManifest();
     }
 }
        /// <summary>
        /// Determines whether the game manifest is outdated.
        /// </summary>
        /// <returns><c>true</c> if the manifest is outdated; otherwise, <c>false</c>.</returns>
        private bool IsGameManifestOutdated()
        {
            if (File.Exists(ManifestHandler.GetGameManifestPath()))
            {
                string remoteHash = GetRemoteGameManifestChecksum();

                using (Stream file = File.OpenRead(ManifestHandler.GetGameManifestPath()))
                {
                    string localHash = MD5Handler.GetStreamHash(file);

                    return(remoteHash != localHash);
                }
            }
            else
            {
                return(true);
            }
        }
        /// <summary>
        /// Determines whether or not the local copy of the manifest for the specifed module is outdated.
        /// </summary>
        /// <exception cref="ArgumentOutOfRangeException">
        /// Will be thrown if the <see cref="EModule"/> passed to the function is not a valid value.
        /// </exception>
        protected virtual bool IsModuleManifestOutdated(EModule module)
        {
            string manifestPath;

            switch (module)
            {
            case EModule.Launcher:
            {
                manifestPath = ManifestHandler.GetLaunchpadManifestPath();
                break;
            }

            case EModule.Game:
            {
                manifestPath = ManifestHandler.GetGameManifestPath();
                break;
            }

            default:
            {
                throw new ArgumentOutOfRangeException(nameof(module), module,
                                                      "An invalid module value was passed to RefreshModuleManifest.");
            }
            }

            if (File.Exists(manifestPath))
            {
                string remoteHash = GetRemoteModuleManifestChecksum(module);
                using (Stream file = File.OpenRead(manifestPath))
                {
                    string localHash = MD5Handler.GetStreamHash(file);

                    return(remoteHash != localHash);
                }
            }

            return(true);
        }
        /// <summary>
        /// Refreshes the current manifest by redownloading it, if required;
        /// </summary>
        /// <exception cref="ArgumentOutOfRangeException">
        /// Will be thrown if the <see cref="EModule"/> passed to the function is not a valid value.
        /// </exception>
        protected virtual void RefreshModuleManifest(EModule module)
        {
            bool doesManifestExist;

            switch (module)
            {
            case EModule.Launcher:
            {
                doesManifestExist = File.Exists(ManifestHandler.GetLaunchpadManifestPath());
                break;
            }

            case EModule.Game:
            {
                doesManifestExist = File.Exists(ManifestHandler.GetGameManifestPath());
                break;
            }

            default:
            {
                throw new ArgumentOutOfRangeException(nameof(module), module,
                                                      "An invalid module value was passed to RefreshModuleManifest");
            }
            }

            if (doesManifestExist)
            {
                if (IsModuleManifestOutdated(module))
                {
                    DownloadModuleManifest(module);
                }
            }
            else
            {
                DownloadModuleManifest(module);
            }
        }