Code: Select all
private void InstallGameFiles(bool _isUpdate, Version _onlineVersion)
{
try
{
WebClient webClient = new WebClient();
if (_isUpdate)
{
Status = LauncherStatus.downloadingUpdate;
}
else
{
Status = LauncherStatus.downloadingGame;
_onlineVersion = new Version(webClient.DownloadString("https://www.dropbox.com/scl/fi/9wc1btx28iz03rr3r6gkt/Version.txt?rlkey=67mgp885v82m9qdafan1se469&st=h7lchvjt&dl=0"));
}
webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(DownloadGameCompletedCallback);
webClient.DownloadFileAsync(new Uri("https://www.dropbox.com/scl/fi/3evjysl179fjrnvxx9uu8/Build.zip?rlkey=c1rcmm7qd0n95whwmc2c2inos&st=yntg8128&dl=0"), gameZip, _onlineVersion);
}
catch (Exception ex)
{
Status = LauncherStatus.failed;
MessageBox.Show($"Error installing game files: {ex}");
}
}
private void DownloadGameCompletedCallback(object sender, AsyncCompletedEventArgs e)
{
try
{
string onlineVersion = ((Version)e.UserState).ToString();
ZipFile.ExtractToDirectory(gameZip, rootPath, true);
File.Delete(gameZip);
File.WriteAllText(versionFile, onlineVersion);
VersionText.Text = onlineVersion;
Status = LauncherStatus.ready;
}
catch (Exception ex)
{
Status = LauncherStatus.failed;
MessageBox.Show($"Error Downloading: {ex}");
}
}