升级程序更新

This commit is contained in:
wule committed 2026-08-26 15:54:11 +08:00
1 parent 8874820269
commit cf567144a3
1 file changed
+26 -9
+26 -9
View File
@@ -6,6 +6,8 @@ using System.Drawing;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net;
using System.Reflection.Emit;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@@ -69,22 +71,37 @@ namespace Update
progressBar1.Visible = true;
progressBar1.Maximum = 100;//fileNameArr.Count();
progressBar1.Value = 0;
new TaskFactory().StartNew(() =>
Task.Run(async() =>
{
string tempFile = upTempPath + "\\" + Program.updateUrl.Substring(Program.updateUrl.LastIndexOf("/") + 1);
bool result = Program.DownloadFile(Program.updateUrl, tempFile);
//bool result = Program.DownloadFile(Program.updateUrl, tempFile);
while (true)
//while (true)
//{
// Invoke(new Action(() =>
// {
// progressBar1.Value = Program.progress;
// }));
// if (Program.progress == 100)
// break;
//}
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
using (var downloadClient = new WebClient())
{
Invoke(new Action(() =>
downloadClient.Proxy = null;
downloadClient.DownloadProgressChanged += (s, args) =>
{
progressBar1.Value = Program.progress;
}));
if (Program.progress == 100)
break;
Invoke(new Action(() => { progressBar1.Value = args.ProgressPercentage; }));
};
await downloadClient.DownloadFileTaskAsync(new Uri(Program.updateUrl), tempFile);
}
if (result)
if (1 == 1)
//if (result)
{
ZipFile.ExtractToDirectory(tempFile, upTempPath);
File.Delete(tempFile);