升级程序更新
This commit is contained in:
1 parent
8874820269
commit
cf567144a3
1 file changed
+26
-9
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user