Skip to content

Commit

Permalink
Merge pull request #67 from hignz/master
Browse files Browse the repository at this point in the history
fix auto update crash on launch
  • Loading branch information
Just2good authored Jul 13, 2019
2 parents 3421379 + 603c795 commit fc1dbde
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ private void AutoUpdater(object sender, StartupEventArgs e)

using (WebClient client = new WebClient())
{
string htmlCode = client.DownloadString("https://raw.githubusercontent.com/Just2Good/TFT-Overlay/master/Version.cs");
int versionFind = htmlCode.IndexOf("public static string version = ");
version = htmlCode.Substring(versionFind + 32, 5);
if (currentVersion != version && Settings.Default.AutoUpdate)
try
{
var result = MessageBox.Show($"A new update is available.\nWould you like to download V{version}?", "TFT Overlay Update Available", MessageBoxButton.YesNo, MessageBoxImage.Question);

if (result == MessageBoxResult.Yes)
string htmlCode = client.DownloadString("https://raw.githubusercontent.com/Just2Good/TFT-Overlay/master/Utilities/Version.cs");
int versionFind = htmlCode.IndexOf("public static string version = ");
version = htmlCode.Substring(versionFind + 32, 5);
if (currentVersion != version && Settings.Default.AutoUpdate)
{
try
var result = MessageBox.Show($"A new update is available.\nWould you like to download V{version}?", "TFT Overlay Update Available", MessageBoxButton.YesNo, MessageBoxImage.Question);

if (result == MessageBoxResult.Yes)
{
string link = "https://github.com/Just2good/TFT-Overlay/releases/download/V" + version + "/TFT.Overlay.V" + version + ".rar";
ServicePointManager.Expect100Continue = true;
Expand All @@ -39,16 +39,16 @@ private void AutoUpdater(object sender, StartupEventArgs e)
Process.Start(Directory.GetCurrentDirectory());
}
}
catch (WebException ex)
else if (result == MessageBoxResult.No)
{
Console.WriteLine(ex.Message);
MessageBox.Show(ex.Message, "An error occured", MessageBoxButton.OK, MessageBoxImage.Error);
Settings.FindAndUpdate("AutoUpdate", false);
}
}
else if (result == MessageBoxResult.No)
{
Settings.FindAndUpdate("AutoUpdate", false);
}
}
catch (WebException ex)
{
Console.WriteLine(ex);
MessageBox.Show(ex.ToString(), "An error occured", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}
Expand Down

0 comments on commit fc1dbde

Please sign in to comment.