DiscordMediaLoader/Discord Media Loader/FrmSplash.cs

60 lines
1.9 KiB
C#
Raw Normal View History

2017-04-16 17:57:27 +02:00
using System;
using System.IO;
using System.IO.Compression;
using System.Windows.Forms;
using Discord_Media_Loader.Helper;
namespace Discord_Media_Loader
{
public partial class FrmSplash : Form
{
public FrmSplash()
{
InitializeComponent();
}
private async void FrmSplash_Shown(object sender, EventArgs e)
{
UseWaitCursor = true;
try
{
2017-10-12 21:28:02 +02:00
var releaseVersion = await VersionHelper.GetReleaseVersion();
if (releaseVersion > VersionHelper.AppVersion)
2017-04-16 17:57:27 +02:00
{
var tmpFile = Path.GetTempFileName();
var downloadManager = new FrmDownload(tmpFile, await VersionHelper.DownloadVersion(releaseVersion));
downloadManager.StartDownload();
downloadManager.ShowDialog();
2017-05-02 13:32:37 +02:00
var tmpFolder = Path.GetTempFileName();
tmpFolder = Path.Combine(Path.GetFullPath(tmpFolder).Replace(Path.GetFileName(tmpFolder), ""), Path.GetFileNameWithoutExtension(tmpFolder));
2017-05-02 13:32:37 +02:00
var di = Directory.CreateDirectory(tmpFolder);
ZipFile.ExtractToDirectory(tmpFile, tmpFolder);
foreach (var f in di.GetFiles())
{
try
{
var fname = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, f.Name);
File.Copy(f.FullName, fname, true);
}
catch (Exception) { }
}
2017-04-16 17:57:27 +02:00
File.Delete(tmpFile);
DialogResult = DialogResult.Cancel;
2017-10-12 21:28:02 +02:00
}
2017-04-16 17:57:27 +02:00
}
finally
{
UseWaitCursor = false;
}
DialogResult = DialogResult.OK;
2017-04-16 17:57:27 +02:00
}
}
}