I have this code and the loading bar is just from 0 to 100, how i can do to solve that, because i don’t want to be everytime 0% and when is done to be 100%
What i can do?
private void worker_DoWork(object sender, DoWorkEventArgs e)
{
string filePathDir = File.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\Astro And Aliens Launcher\Data\" + dataFileName);
int total = 1;
for (int i = 0; i <= total; i++)
{
Thread.Sleep(100);
int percents = (i * 100) / total;
worker.ReportProgress(percents, i);
WebClient wc = new WebClient();
Stream zipReadingStream = wc.OpenRead(url);
ZipArchive zip = new ZipArchive(zipReadingStream);
zip.ExtractToDirectory(filePathDir, _progress);
}
}
private void Worker_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
UpdateProgress.Visibility = Visibility.Visible;
updatePercentText.Visibility = Visibility.Visible;
UpdateProgress.Minimum = 0;
UpdateProgress.Value = e.ProgressPercentage;
updatePercentText.Content = String.Format("Downloading: {0}%", e.ProgressPercentage);
}