I have a question, I'm using WebClient in C # language, I have the following problem: I click on Download a file, and it does not start downloading, it says download is already finished ...
Code:
WebClient Web = new WebClient();
string Info = Web.DownloadString("https://drive.google.com/uc?authuser=0&id=1_bujHdC26AyVeFUZc-5UbDV-g8UuGdXS&export=download");
string VAtualizada = Info.Split('\n')[0];
V1 = VAtualizada.Split('.')[0];
V2 = VAtualizada.Split('.')[1];
V3 = VAtualizada.Split('.')[2];
metroLabel2.Text = "Versão mais recente: V" + VAtualizada;
frmGerador.Versao = VAtualizada;
Web.DownloadProgressChanged += new DownloadProgressChangedEventHandler(Web_DownloadProgress);
Web.DownloadFileCompleted += new AsyncCompletedEventHandler(Web_DownloadCompleted);
Web.DownloadFileAsync(new Uri(Info.Split('\n')[1]), Application.StartupPath + @"\Gerador de Deck V" + V1 + "." + V2 + "." + V3 + " - Clash Royale.exe");
DownloadFileCompleted event:
void Web_DownloadCompleted(object sender, AsyncCompletedEventArgs e)
{
MessageBox.Show("A nova versão foi baixada com sucesso." + Environment.NewLine + "O programa será reiniciado.", "Atualização", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
Can anyone tell me why the error? And also in the DownloadProgress event I can only get the following information: e.BytesReceived
Code:
void Web_DownloadProgress(object sender, DownloadProgressChangedEventArgs e)
{
metroLabel5.Text = "Baixado: " + e.BytesReceived / 1024 + "KB";
}
Summarizing my doubts so far: - When you click Download, the file says: "New version downloaded successfully." without downloading. (Before it was normal, not now) - I can not use e.TotalBytesToReceive and e.ProgressPorcentage properties in the DownloadProgress method
Can anyone help me? Comment here below any questions!