My program has an Update button that downloads the latest version zip from GitHub.
It worked for many months but now the progress bar no longer updates and it doesn't download a file from the GitHub Release URL.
However, I tested it with a Google Drive URL and it works, but URL naming convention won't be compatible with this project.
Is there a way to get around it with the code, or is does this have something to do with GitHub server rules?
Download Handlers
// Progress Changed
//
public void wc_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
// Progress Bar
this.Dispatcher.BeginInvoke((Action)(() =>
{
double bytesIn = double.Parse(e.BytesReceived.ToString());
double totalBytes = double.Parse(e.TotalBytesToReceive.ToString());
double percentage = bytesIn / totalBytes * 100;
this.progressBar.Value = int.Parse(Math.Truncate(percentage).ToString());
}));
}
// Download Complete
//
public void wc_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
{
// Set the waiter Release
// Must be here
this.Dispatcher.BeginInvoke((Action)(() =>
{
waiter.Set();
}));
}
Download Method
In the actual code, the version number is a string that dynamically changes in the URL.
Doesn't Work:
https://github.com/MattMcManis/Glow/releases/download/v0.0.5.4-alpha/Glow.zip
Works:
https://drive.google.com/uc?authuser=0&id=1_7hzLR4FFZXK6qr2sP0uOleeB2GgtghE&export=download
public void StartDownload()
{
// Start New Thread
Thread worker = new Thread(() =>
{
waiter = new ManualResetEvent(false);
Uri downloadUrl = new Uri("https://github.com/MattMcManis/Glow/releases/download/v0.0.5.4-alpha/Glow.zip);
//Async
wc.DownloadProgressChanged += new DownloadProgressChangedEventHandler(wc_DownloadProgressChanged);
wc.DownloadFileCompleted += new AsyncCompletedEventHandler(wc_DownloadFileCompleted);
wc.DownloadFileAsync(downloadUrl, tempDir + "Glow.zip");
// Wait for Download to finish
waiter.WaitOne();
});
// Start Download Thread
worker.Start();
}