Skip to content
This repository has been archived by the owner on Dec 24, 2020. It is now read-only.

Commit

Permalink
Brightness Controller 2.0.0.4
Browse files Browse the repository at this point in the history
- Improve update fuction.
  • Loading branch information
MinorMole committed Oct 13, 2019
1 parent bb5e93f commit 7581d1f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
22 changes: 10 additions & 12 deletions Brightness Controller/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -565,9 +565,7 @@ private void RestartProgram(string location)

private async void Updater()
{
await Task.Delay(1);
string NewExeLocations = AppDomain.CurrentDomain.BaseDirectory + "Brightness Controller.exe";
MessageBox.Show(NewExeLocations);
await Task.Delay(60000);
try
{
using (WebClient client = new WebClient())
Expand All @@ -577,24 +575,23 @@ private async void Updater()
if (CheckVersion.Contains(".") & Application.ProductVersion != CheckVersion)
{
string ExeLocation = System.Reflection.Assembly.GetEntryAssembly().Location;
string NewExeLocation = AppDomain.CurrentDomain.BaseDirectory + @"\Brightness Controller.exe";
string NewExeLocation = AppDomain.CurrentDomain.BaseDirectory + "Brightness Controller.exe";
try
{
client.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.NoCacheNoStore);
client.DownloadFile("https://minormole.github.io/Brightness_Controller/update/Brightness%20Controller.zip", ExeLocation + ".new");
if (File.Exists(ExeLocation + ".new"))
client.DownloadFile("https://minormole.github.io/Brightness_Controller/update/Brightness%20Controller.zip", NewExeLocation + ".new");
if (File.Exists(NewExeLocation + ".new"))
{
File.Move(ExeLocation, ExeLocation + ".old");
ZipFile.ExtractToDirectory(ExeLocation + ".new", AppDomain.CurrentDomain.BaseDirectory);
File.Delete(ExeLocation + ".new");
RestartProgram(ExeLocation);
File.Move(ExeLocation, NewExeLocation + ".old");
ZipFile.ExtractToDirectory(NewExeLocation + ".new", AppDomain.CurrentDomain.BaseDirectory);
File.Delete(NewExeLocation + ".new");
RestartProgram(NewExeLocation);
}
}
catch (Exception)
{
try
{
File.Delete(ExeLocation + ".new");
File.Delete(NewExeLocation + ".new");
}
catch (Exception) { }
}
Expand All @@ -603,6 +600,7 @@ private async void Updater()
}
catch (Exception) { }
}

}

public class BrightnessController : IDisposable
Expand Down
Binary file modified update/Brightness Controller.exe
Binary file not shown.
Binary file modified update/Brightness Controller.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion update/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.0.3
2.0.0.4

0 comments on commit 7581d1f

Please sign in to comment.