Hello!
Did I implement it properly? Is there some better way to do this? here's my code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace HawkEyezxsj
{
public partial class WND_Main : Form
{
WebClient Client = new WebClient();
int counter = 0;
public string[] ListOfFiles = File.ReadAllLines("list.txt");
public WND_Main()
{
InitializeComponent();
}
private void BTN_GetUpdate_Click(object sender, EventArgs e)
{
Client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(Client_DownloadProgressChanged);
Client.DownloadFileCompleted += new AsyncCompletedEventHandler(Client_DownloadFileCompleted);
foreach (var item in ListOfFiles)
{
Client.DownloadFileAsync(new System.Uri("https://nuno-software.pl/projects/HawkEye/" + item + ""),item);
}
Client.DownloadFileAsync(new System.Uri("https://nuno-software.pl/projects/HawkEye/HawkEye_Demo.exe"), "HawkEye_Demo.exe");
BTN_GetUpdate.Text = "Downloading";
BTN_GetUpdate.Enabled = false;
}
void Client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
PRG_Download.Value = e.ProgressPercentage;
}
void Client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
{
counter++;
if (counter == ListOfFiles.Length)
{
MessageBox.Show("The update has been downloaded and applied. The program will be started now.");
Process.Start("HawkEye_Demo.exe");
this.Close();
}
}
private void PRG_Download_Click(object sender, EventArgs e)
{
}
}
}
Telegram: Nuno69a
E-Mail: nuno69a (at) gmail (dot) com